#include<bits/stdc++.h>
using namespace std;
const int maxn=205;
const int inf=0x3f3f3f3f;
int a[maxn],vis[maxn],n,s,t;
struct ss{
int step,x;
};
void bfs(){
queue<ss> q;
ss cur,nex;
cur.x=s;
cur.step=0;
q.push(cur);
vis[s]=0;
while(!q.empty()){
cur=q.front();
q.pop();
if(cur.x==t) {
cout<<cur.step<<endl;
return;
//不用break 直接return方便后面输出-1
}
nex.x=cur.x+a[cur.x];
if(nex.x<=n&&vis[nex.x]){
nex.step=cur.step+1;
q.push(nex);
vis[nex.x]=0;
}
nex.x=cur.x-a[cur.x];
if(nex.x>=1&&vis[nex.x]){
nex.step=cur.step+1;
q.push(nex);
vis[nex.x]=0;
}
}
puts("-1");
return ;
}
int main(){
while(cin>>n>>s>>t){
if(n==0) break;
for(int i=1;i<=n;i++) {
cin>>a[i];
vis[i]=1;
}
bfs();
}
}