#include<iostream>
#include<cstdlib>
using namespace std;
bool cs=0;
int N,A,B,a[201][2];
int book[201];
int total=999999999;
void gala(int l,int step)
{
if(l==B)
{
cs=1;
if(step<=total)
{
total=step;
}
return;
}
int nl;
for(int i=0;i<=1;i++)
{
nl=l+a[l][i];
if(nl>N||nl<1)
continue;
if(book[nl]==0)
{
book[nl]=1;
gala(nl,step+1);
book[nl]=0;
}
}
return;
}
int main()
{
cin>>N>>A>>B;
for(int i=1;i<=N;i++)
{
int k;
cin>>k;
a[i][0]=k;
a[i][1]=-k;
}
book[A]=1;
gala(A,0);
cout<<total;
if(cs==0)
cout<<-1;
return 0;
}```