#include <bits/stdc++.h>
using namespace std;
int n, a, b, k[205], ans = INT_MAX;
bool vis[205];
void dfs(int depth, int cnt) {
if (depth == b) {
ans = min(cnt, ans);
vis[depth] = false;
return;
}
if (cnt > ans)return;
vis[depth] = true;
if (depth + k[depth] <= n && !vis[depth + k[depth]])dfs(depth + k[depth], cnt + 1);
else if (depth - k[depth] >= 1 && !vis[depth - k[depth]])dfs(depth - k[depth], cnt + 1);
vis[depth] = false;
}
int main() {
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) {
cin >> k[i];
}vis[a] = true;
dfs(a, 0);
if (ans != INT_MAX)cout << ans;
else cout << -1;
return 0;
}