#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int g[N];
int n,a,b;
int ans;
bool vis[N];
void bfs()
{
queue<int> q;
q.push(a);
while(!q.empty())
{
int t = q.front();
vis[t] = true;
q.pop();
if(t == b) return ;
if((g[t]+t)>=1 && (g[t]+t)<=n && !vis[g[t]+t]) {q.push(g[t]+t);ans++;}
if((g[t]-t)>=1 && (g[t]-t)<=n && !vis[g[t]-t]) {q.push(g[t]-t);ans++;}
}
ans = -1;
}
int main()
{
memset(vis,false,sizeof(vis));
cin >> n >> a >> b;
for(int i=1;i<=n;i++)
{
int t;
cin >> t;
g[i] = t;
}
bfs();
cout << ans;
return 0;
}