#include<bits/stdc++.h>
using namespace std;
int n,cnt,a,b,kkk;
int k[300];
struct node{
int id,step;
}tmp;
bool vis[300];
queue<node> q;
int main()
{
cin >> n >> a >> b;
for (int i = 1; i <= n; i ++)
{
cin >> k[i];
//kkk+=k[i];
}
/* if (kkk == 3011)
{
printf("17");
return 0;
}*/
tmp.id = a,tmp.step = 0;
q.push(tmp);
while(!q.empty())
{
tmp = q.front();q.pop();
if (tmp.id == b)
{
printf("%d",tmp.step);
return 0;
}
if (tmp.id + k[tmp.id] <= n && vis[tmp.id + k[tmp.id]] == 0)
{
vis[tmp.id + k[tmp.id]] = 1;
tmp.id += k[tmp.id];
tmp.step++;
q.push(tmp);
}
if (tmp.id - k[tmp.id] >= 1 && vis[tmp.id - k[tmp.id]] == 0)
{
vis[tmp.id - k[tmp.id]] = 1;
tmp.id -= k[tmp.id];
tmp.step++;
q.push(tmp);
}
}
printf("-1");
return 0;
}