#include<iostream>
#include<cstdio>
using namespace std;
int k[300], st, fs, ans = 9999999,n;
bool book[300];
void dfs(int x, int num)
{
if (x == fs)
{
ans = min(ans, num);
return;
}
if (num > ans)
return;
for (int i = -1; i <= 1; i += 2)
{
int xx = x + i * k[x];
if (xx >= 1 && xx <= n)
{
if (book[xx] == 0)
{
book[xx] = 1;
dfs(xx, num + 1);
book[xx] = 0;
}
}
}
}
int main()
{
scanf("%d%d%d", &n, &st, &fs);
for (int i = 1; i <= n; i++)
scanf("%d", &k[i]);
dfs(st, 0);
if (ans == 9999999)
printf("-1");
else printf("%d", ans);
return 0;
}