#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "string" #include "map" #include "iomanip" #include "cmath" using namespace std; const long long int MOD = 1000000007; long long int N, M, K, H, W, L, R; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; vectoro; vectore; for (int i = 0; i < N; i++) { cin >> M; if (M % 2) { o.push_back(M); } else { e.push_back(M); } } long long int a, b; cin >> a >> b; a = abs(a); b = abs(b); if (!a && !b) { cout << "0\n"; return 0; } for (auto i : e) { if (i == a + b) { cout << "1\n"; return 0; } } for (auto i : o) { if (i == a + b) { cout << "1\n"; return 0; } } sort(o.begin(), o.end()); sort(e.begin(), e.end()); if ((a + b) % 2) { for (auto i : o) { L = abs(a + b - i); R = a + b + i; if (lower_bound(e.begin(), e.end(), L) != upper_bound(e.begin(), e.end(), R)) { cout << "2\n"; return 0; } } } else { for (auto i : e) { L = abs(a + b - i); R = a + b + i; if (lower_bound(e.begin(), e.end(), L) != upper_bound(e.begin(), e.end(), R)) { cout << "2\n"; return 0; } } for (auto i : o) { L = abs(a + b - i); R = a + b + i; if (lower_bound(o.begin(), o.end(), L) != upper_bound(o.begin(), o.end(), R)) { cout << "2\n"; return 0; } } } cout << "-1\n"; return 0; }