#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
int k[210];
int s[210][3];
int head,rear;
bool isUse[210];
int main(){
int n,a,b;
cin>>n>>a>>b;
for(int i=1;i<=n;i++){
cin>>k[i];
}
rear++;
s[rear][0]=a;
s[rear][1]=0;
while(head<rear){
head++;
int x=s[head][0],y=s[head][1];
if(x==b){
cout<<y;
return 0;
}
int x1=x+k[x];
int x2=x-k[x];
if(x1>=1&&x1<=n){
rear++;
s[rear][0]=x1;
s[rear][1]=y+1;
}
if(x2>=1&&x2<=n){
rear++;
s[rear][0]=x2;
s[rear][1]=y+1;
}
}
return 0;
}