#include<bits/stdc++.h>
#define fi first
#define se second
#define  pii pair<int,int>
using namespace std;
const int maxn=2e2+10;
const int inf = 0x3f3f3f3f;
vector<int> vs[maxn];
priority_queue<pii> que;
int dis[maxn];

void dij(int s){
    memset(dis,inf,sizeof(dis));
    que.push(pii(0,s));
    dis[s] = 0;
    while(!que.empty()){
        int u = que.top().se; que.pop();
        for(int i=0; i<vs[u].size(); i++)
        {
            int v = vs[u][i];
            if(dis[v] > dis[u] + 1) {
                dis[v] = dis[u] + 1;
                que.push(pii(-1*dis[v],v));
            }
        }
    }
}
int main()
{
    while(1)
    {

        int n;   cin>>n;

        if(!n)   break;
        int l,r; cin>>l>>r;
        for(int i=1;i<=n;i++)
        {
            int x; cin>>x;
            if(i-x>=1) vs[i].push_back(i-x);
            if(i+x<=n) vs[i].push_back(i+x);
        }
        dij(l);
        for(int i=1;i<=n;i++)
            vs[i].clear();
        if(dis[r]!=inf) cout<<dis[r]<<endl;
        else  cout<<-1<<endl;
    }
}