#include<bits/stdc++.h> using namespace std; int n,b,a,ans; int x[201]; bool y[201]; queue<int> q; void bfs(){ while(!q.empty()){ ans++; int xx=q.front(); int tx=xx+x[xx]; int ty=xx-x[xx]; if(tx==a||ty==a){ cout<<ans; return; } if(tx>=1&&tx<=n&&y[tx]==0){ q.push(tx); y[tx]=1; } if(ty>=1&&ty<=n&&y[ty]==0){ q.push(ty); y[ty]=1; } q.pop(); } } int main(){ cin>>n>>b>>a; for(int i=1;i<=n;i++) { cin>>x[i]; } q.push(b); y[b]=1; bfs(); } /************************************************************** Problem: 1819 User: wuyunfeng Language: C++ Result: Wrong Answer ****************************************************************/