#include #define VARNAME(x) #x #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; template ostream& operator<<(ostream& os, const vector& v) { os << "sz:" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = (ll)1e9 + 7LL; template constexpr T INF = numeric_limits::max() / 64; int main() { int N; cin >> N; vector d(N); vector odd; vector even; for (int i = 0; i < N; i++) { cin >> d[i]; ((d[i] % 2 == 0) ? even : odd).push_back(d[i]); } ll x, y; cin >> x >> y; const ll dist = abs(x) + abs(y); const ll maxi = *max_element(d.begin(), d.end()); if (dist == 0) { cout << 0 << endl; return 0; } for (int i = 0; i < N; i++) { if (d[i] == dist) { cout << 1 << endl; return 0; } } if (dist > maxi * 2) { cout << -1 << endl; } else if (dist % 2 == 0) { cout << 2 << endl; } else if (even.empty() or odd.empty()) { cout << -1 << endl; } else { const ll oddmaxi = *max_element(odd.begin(), odd.end()); const ll evenmaxi = *max_element(even.begin(), even.end()); if (dist >= abs(oddmaxi - evenmaxi) and dist <= oddmaxi + evenmaxi) { cout << 2 << endl; } else { cout << -1 << endl; } } return 0; }