#include <iostream>
using namespace std;
const int N = 220;
int p[N];
int n,x,y;
int ox[] = {1,-1};
int count;
int dst[N];
bool dfs(int x,int y){
if(x==y){
return true;
}
count++;
dst[x]==1;
for(int i=0;i<2;i++){
int nx = x+(ox[i]*p[x]);
if(nx>=1&&nx<=y&&nx!=x&&!dst[nx]){
if(dfs(nx,y)){
return true;
}
count--;
dst[nx] = 0;
}
}
return false;
}
int main(){
cin>>n>>x>>y;
for(int i=1;i<=n;i++) cin>>p[i];
bool bl = dfs(x,y);
if(bl){
cout << count << endl;
}else {
cout << -1 << endl;
}
return 0;
}
四个MLE,剩下都AC,姥姥救救