#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
int main(){
queue<long long> q;
int N, A, B;
cin>>N>>A>>B;
long long a[N+1], b[N+1], c[N+1];
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
for(int i=1;i<=N;i++){
cin>>a[i];
}
q.push(A);
while(!q.empty()){
if(b[q.front()] == 0){
b[q.front()] = c[q.front()];
if(q.front()+a[q.front()] <= N){
q.push(q.front()+a[q.front()]);
c[q.front()+a[q.front()]] = c[q.front()]+1;
}
if(q.front()-a[q.front()]>0){
q.push(q.front()-a[q.front()]);
c[q.front()-a[q.front()]] = c[q.front()]+1;
}
}
q.pop();
if(b[B] != 0)
break;
}
if(b[B] != 0)
cout<<b[B];
else cout<<-1;
return 0;
}