#include using namespace std; typedef long long ll; ll d[100000]; int main(){ cin.tie(0); ios::sync_with_stdio(false); #ifdef LOCAL std::ifstream in("in"); std::cin.rdbuf(in.rdbuf()); #endif int N; cin >> N; set s; for(int i = 0; i < N; i++){ cin >> d[i]; s.insert(d[i]); } sort(d, d + N); ll x, y; cin >> x >> y; ll D = abs(x) + abs(y); if(D == 0){ cout << 0 << endl; return 0; } if(s.count(D)){ cout << 1 << endl; return 0; } for(int i = 0; i < N; i++){ int r = upper_bound(d, d + N, D + d[i] + 1) - d; int l = lower_bound(d, d + N, abs(D - d[i])) - d; if(r - l >= 1){ cout << 2 << endl; return 0; } } cout << -1 << endl; }