#include <iostream>
#include <queue>
using namespace std;
int n,a,b;
int k[210];
int lou[210],ans[210];
int t,t1,t2,m;
queue<int>q;
int main()
{
cin>>n>>a>>b;
if (a==b)
{
cout<<0<<endl;
return 0;
}
q.push(a);
lou[a]=1;
for (int i=1;i<=n;i++)
{
cin>>k[i];
ans[i]=114514;
}
for (int i=1;i<=n;i++)
{
t1=i+k[i];
t2=i-k[i];
cout<<i<<' '<<t1<<' '<<t2<<endl;
}
ans[a]=0;
while(!q.empty())
{
t=q.front();
q.pop();
t1=t+k[t];
t2=t-k[t];
cout<<t<<' '<<t1<<' '<<t2<<endl;
if (t1<=n)
{
if(ans[t1]!=114514)
{
if(ans[t1] < ans[t] + 1)
continue;
else
{
ans[t1] = ans[t] + 1;
q.push(t1);
}
}
else
{
ans[t1] = ans[t] + 1;
q.push(t1);
}
}
if (t2>=1)
{
if(ans[t2]!=114514)
{
if(ans[t2] < ans[t] + 1)
continue;
else
{
ans[t2] = ans[t] + 1;
q.push(t2);
}
}
else
{
ans[t2] = ans[t] + 1;
q.push(t2);
}
}
}
if(ans[b]!=114514)
{
cout<<ans[b]<<endl;
return 0;
}
cout<<-1<<endl;
return 0;
}