#include <bits/stdc++.h>
using namespace std;
int n, a, b, k[250];
struct P
{
int lc;
int step;
P(int x, int s)
{
lc = x;
step = s;
}
};
queue<P> q;
int vis[250];
int bfs(int x)
{
q.push(P(x, 0));
vis[x] = 1;
while (!q.empty())
{
P u = q.front();
q.pop();
if (u.lc == b)
return u.step;
if (u.lc + k[u.lc] <= n && vis[u.lc + k[u.lc]] == 0)
{
q.push(P(u.lc + k[u.lc], u.step + 1));
vis[u.lc + k[u.lc]] = 1;
}
if (u.lc - k[u.lc] >= 1 && vis[u.lc - k[u.lc]] == 0)
{
q.push(P(u.lc - k[u.lc], u.step + 1));
vis[u.lc - k[u.lc]] = 1;
}
}
return -1;
}
int main()
{
cin >> n >> a >> b;
for (int i = 1; i <= n; i++)
cin >> k[i];
cout << bfs(a);
return 0;
}