#include<bits/stdc++.h>
using namespace std;
int n,A,B;
int ans = 1e9;
int a[220];
bool f0 = false;
struct node{
bool up;
bool down;
}f[220];
void dfs(int step, int cnt){
if(cnt >= ans) return;
if(step == B){
ans = min(ans,cnt);
f0 = true;
}
if(step+a[step] <= n && !f[step].up){
f[step].up = true;
dfs(step+a[step], cnt+1);
}
if(step-a[step] >= 1 && !f[step].down){
f[step].down = true;
dfs(step-a[step], cnt+1);
}
}
int main(){
scanf("%d%d%d",&n,&A,&B);
for(int i = 1; i <= n; i++){
scanf("%d",&a[i]);
}
dfs(A,0);
if(f0) cout << ans;
else cout << -1;
return 0;
}