#include <iostream>
using namespace std;
int n,a,b;
int p[200];
void bfs(int now,int time){
if(now == b){
cout << time;
return;
}
if(now <= 0 or now > n){
return;
}
if(p[now - 1] == 0){
cout << "-1";
return;
}
if(now + p[now - 1] >= 1 && now - p[now - 1] <= n){
time++;
int d = p[now - 1];
p[now - 1] = 0;
bfs(now + d,time);
bfs(now - d,time);
}
}
int main(){
cin >> n >> a >> b;
for(int i = 0;i < n;i++){
cin >> p[i];
}
bfs(a,0);
return 0;
}