#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0; i=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector VI; typedef vector VL; typedef vector VVI; typedef vector VVL; typedef pair P; typedef pair PL; int main() { int n; cin >> n; VL d(n); set st; REP(i,n){ scanf("%lld", &d[i]); st.insert(d[i]); } sort(ALL(d)); ll xx, yy; cin >> xx >> yy; ll x = xx + yy, y = xx - yy; x = abs(x); y = abs(y); if (y > x) swap(x, y); REP(i,n){ if (d[i] == x){ cout << 1 << endl; return 0; } } REP(i,n){ if (st.count(abs(x - d[i]))){ cout << 2 << endl; return 0; } } VL d_even, d_odd; REP(i,n){ if (d[i] % 2 == 0) d_even.push_back(d[i]); else d_odd.push_back(d[i]); } d_even.push_back(1e17); d_odd.push_back(1e17); for (int d : d_even){ if (y % 2 == 0){ ll p = *lower_bound(ALL(d_even), abs(x - d)); if (p <= x + d){ cout << 2 << endl; return 0; } }else{ ll p = *lower_bound(ALL(d_odd), abs(x - d)); if (p <= x + d){ cout << 2 << endl; return 0; } } } for (int d : d_odd){ if (y % 2 == 0){ ll p = *lower_bound(ALL(d_odd), abs(x - d)); if (p <= x + d){ cout << 2 << endl; return 0; } }else{ ll p = *lower_bound(ALL(d_even), abs(x - d)); if (p <= x + d){ cout << 2 << endl; return 0; } } } cout << -1 << endl; return 0; }