#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
struct node{
int x;
int step;
};
int b,vis[201],n,w[201];
void bfs(node a){
node q;
queue<node> que;
que.push(a);
vis[a.x] = 1;
while(que.size()){
a = que.front(); que.pop();
for(int i = 0;i<2;++i){
if(i == 0)
q.x = a.x + w[a.x];
else
q.x = a.x - w[a.x];
q.step = a.step + 1;
if(q.x <= 0 || q.x > n)
continue;
else if(vis[q.x] == 1){
int i;
for( i = 1;i<=n;++i)
if(vis[i] == 0)
break;
if(i > n){
cout<<"-1\n";
return;
}
continue;
}
else if(q.x == b){
cout<<q.step<<endl;
return;
}
else{
vis[q.x] = 1;
que.push(q);}
}
}
cout<<"-1\n";
return;
}
int main(){
node a;
while(cin>>n&&n){
cin>>a.x>>b;
a.step = 0;
for(int i = 1;i<=n;++i)
cin>>w[i];
if(a.x == b)
cout<<"0\n";
else{
memset(vis,0,sizeof(vis));
bfs(a);}
}
return 0;
}
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
struct node{
int x;
int step;
};
int b,vis[201],n,w[201];
void bfs(node a){
node q;
queue<node> que;
que.push(a);
vis[a.x] = 1;
while(que.size()){
a = que.front(); que.pop();
for(int i = 0;i<2;++i){
if(i == 0)
q.x = a.x + w[a.x];
else
q.x = a.x - w[a.x];
q.step = a.step + 1;
if(q.x <= 0 || q.x > n)
continue;
else if(vis[q.x] == 1){
int i;
for( i = 1;i<=n;++i)
if(vis[i] == 0)
break;
if(i > n){
cout<<"-1\n";
return;
}
continue;
}
else if(q.x == b){
cout<<q.step<<endl;
return;
}
else{
vis[q.x] = 1;
que.push(q);}
}
}
cout<<"-1\n";
return;
}
int main(){
node a;
while(cin>>n&&n){
cin>>a.x>>b;
a.step = 0;
for(int i = 1;i<=n;++i)
cin>>w[i];
if(a.x == b)
cout<<"0\n";
else{
memset(vis,0,sizeof(vis));
bfs(a);}
}
return 0;
}