#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; constexpr ll dir[5] = {1, 0, -1, 0, 1}; int main() { int N; cin >> N; vector d(N); for (int i = 0; i < N; i++) { cin >> d[i]; } const ll maxi = (*max_element(d.begin(), d.end())); ll x, y; cin >> x >> y; const ll dist = abs(x) + abs(y); if (dist == 0) { cout << 0 << endl; } for(int i = 0; i < N; i++){ if(d[i]==dist){ cout << 1 << endl; return 0; } } if (dist <= 2 * maxi) { cout << 2 << endl; } else { cout << -1 << endl; } return 0; }