#include<bits/stdc++.h>
using namespace std;
int n,a,b,js=0;
int k[201];
bool bj[201];
queue <int> q;
void bfs(int l)
{
bj[l]=1;
q.pop();
if(l==b)
{
bj[b]=1;
return;
}
js++;
if(k[l]+l<=n&&!bj[k[l]+l])
{
q.push(l+k[l]);
}
if(l-k[l]>=1&&!bj[l-k[l]])
{
q.push(l-k[l]);
}
}
int main()
{
cin>>n>>a>>b;
q.push(a);
for(int i=1;i<=n;i++)
{
cin>>k[i];
}
while(!q.empty()&&!bj[b])
{
bfs(q.front());
}
if(bj[b])
{
cout<<js;
}
else
{
cout<<-1;
}
return 0;
}