#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N; int s,t; vector st; vector> E; int main(){ cin >> N; st.resize(N+2); cin >> st[N] >> st[N+1]; rep(i,N) cin >> st[i]; E.resize(N+2); rep(i,N+2) rep(j,N+2) if(i != j) if(!((st[i]^st[j])&((st[i]^st[j])-1))) E[i].push_back(j); vector I = {N}; vector D(N+2,-1); D[N] = 0; rep(i,I.size()){ int p = I[i]; for(int e : E[p]) if(D[e] == -1){ D[e] = D[p] + 1; I.push_back(e); } } if(D[N+1] == -1) cout << "-1\n"; else cout << (D[N+1]-1) << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_inst;