#include <bits/stdc++.h>
using namespace std;
queue<int>q;
bool v[400002];
int o[8424624];
int step[400002];
int main(){
int m,n,k;
cin>>m>>n>>k;
q.push(n);
v[n]=1;
step[n]=1;
for(int i=1;i<=m;i++){
cin>>o[i];
}
if(n==k){
cout<<"0";
}
int l=1;
while(!q.empty()){
l++;
int h=q.front();
if(h==k) break;
q.pop();
if(v[h+o[l]]==0 && h+o[l]<=m){
q.push(h+o[l]);
v[h+o[l]]=1;
step[h+o[l]]=step[h]+1;
}
if(v[h-o[l]]=0 && h-o[l]>=0){
q.push(h-o[l]);
v[h-o[l]]=1;
step[h-o[l]]=step[h]+1;
}
}
if(step[k]==0){
cout<<"-1";
return 0;
}
cout<<step[k];
return 0;
}