#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<cstring>
#include <algorithm>
#include<iomanip>
#include<iostream>
using namespace std;
#define ListSize 50000
int n,a,b;
int k[300];
int linkList[ListSize];
int head=0,tail=0;
int step;
bool vis[300];
int main()
{
cin>>n>>a>>b;
for(int i=1;i<=n;i++)
{
cin>>k[i];
}
linkList[tail++]=a;
linkList[tail++]=-1;
vis[a]=true;
while(true)
{
if(head==tail)
break;
int h=linkList[head++];
if(h==-1)
{
linkList[tail++]=-1;
step++;
continue;
}
if(h==b)
{
cout<<step;
return 0;
}
if(h+k[h]<=n&&vis[h+k[h]]==false)
{
linkList[tail++]=h+k[h];
vis[h+k[h]]=true;
}
if(h-k[h]>0&&vis[h-k[h]]==false)
{
linkList[tail++]=h-k[h];
vis[h-k[h]]=true;
}
}
cout<<"-1";
return 0;
}