#include<iostream>
using namespace std;
struct node
{
int cur;
int step;
};
int f=0,r=0,k[1000];
int n,a,b;
bool flag[10000];
node q[10000];
int main(){
cin>>n>>a>>b;
for(int i=1;i<=n;i++){
cin>>k[i];
}
node n1;
n1.cur=a;
n1.step=0;
q[r++]=n1;
while(f<r){
n1=q[f++];
if(n1.cur==b){
cout<<n1.step<<endl;
return 0;
}
for(int i=-1;i<=1;i+=2){
node n2=n1;
n2.cur=n1.cur+i*k[n1.cur];
n2.step++;
if(n2.cur>=1&&n2.cur<=n&&flag[n2.cur]==false){
flag[n2.cur=true];
q[r++]=n2;
}
}
}
cout<<-1<<endl;
return 0;
}