#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n, a, b, k[205], steper = 114514;
ll vis[205];
void dfs(ll x, ll sum) {
if (vis[x]) return ;
vis[x] = 1;
if (x == b) {
steper = (steper > sum ? sum : steper);
}
if (x - k[x] >= 1) {
dfs(x - k[x], sum + 1);
}
if (x + k[x] <= n) {
dfs(x + k[x], sum + 1);
}
}
int main() {
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) {
cin >> k[i];
}
dfs(a, 0);
if (steper == 114514) {
cout << -1;
} else {
cout << steper;
}
return 0;
}
记录