#include<cstdlib>
#include<cstring>
int ans=0,n,f;
int a[41000],b[41000];
void dfs(int x)
{
if(x==f)
{
printf("%d",ans);
exit(0);
}
b[x]=1;
if(x+a[x]<=n && b[x+a[x]]!=1)
{
ans++;
dfs(x+a[x]);
ans--;
}
if(x-a[x]>=1 && b[x-a[x]]!=1)
{
ans++;
dfs(x-a[x]);
ans--;
}
b[x]=0;
}
int main()
{
// freopen("elevator.in","r",stdin);
// freopen("elevator.out","w",stdout);
memset(b,0,sizeof(b));
scanf("%d",&n);
int x; scanf("%d %d",&x,&f);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
dfs(x);
printf("-1");
return 0;
}
using namespace std;
int a[201];
bool b[201];
queue<int> q,q1;
int n,x,y,ans=0,tx;
int main(){
cin>>n>>x>>y;
for(int i=1;i<=n;i++)
cin>>a[i];
memset(b,true,sizeof(b));
b[x]=false;
q.push(x);
q1.push(0);
while(!q.empty()){
if(q.front()==y){
cout<<q1.front()<<"\n";
return 0;
}
tx=q.front();
if(b[tx+a[tx]]==true&&tx+a[tx]<=n){
q.push(tx+a[tx]);
q1.push(q1.front()+1);
b[tx+a[tx]]=false;
}
if(b[tx-a[tx]]==true&&tx-a[tx]>=1){
q.push(tx-a[tx]);
q1.push(q1.front()+1);
b[tx-a[tx]]=false;
}
q.pop();
q1.pop();
}
cout<<-1;
return 0;
}