#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
const int N = 210;
int a[N];
int n,start,tail,ans;
int bfs(){
bool vis[N];
memset(vis,false,sizeof vis);
vis[start] = true;
queue<int> q;
q.push(start);
while(q.size()){
if(q.front() == tail) return ans;
int t = q.front();
q.pop();
if(t + a[t] <= n && !vis[t + a[t]]) {
q.push(t + a[t]);
vis[t + a[t]] = true;
}
if(t - a[t] >= 1 && !vis[t - a[t]]) {
q.push(t - a[t]);
vis[t - a[t]] = true;
}
ans ++ ;
}
return -1;
}
int main(){
cin >> n >> start >> tail;
for(int i = 1;i <= n;i ++ ){
cin >> a[i];
}
cout << bfs();
return 0;
}