1 #include<bits/stdc++.h>
2 using namespace std;
3 int n,a,b,tot=10001;
4 int lc[201];
5 bool vis[201];
6 void dfs(int now,int step)
7 {
8 if(step>tot) return ;
9 if(now==b)
10 {
11 if(step<tot)
12 tot=step;
13 return ;
14 }
15 else
16 {
17 vis[now]=1;
18 if(now+lc[now]>0 && vis[now+lc[now]]==0)
19 dfs(now+lc[now],step+1);
20 if(now-lc[now]>0 && vis[now-lc[now]]==0)
21 dfs(now-lc[now],step+1);
22 vis[now]=0;
23 }
24 }
25 int main()
26 {
27 cin>>n>>a>>b;
28 for(int i=1;i<=n;i++)
29 cin>>lc[i];
30 dfs(a,0);
31 if(tot!=10001) cout<<tot;
32 else cout<<-1;
33 return 0;
34 }