#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; VI d(n); REP(i,n) scanf("%d", &d[i]); sort(ALL(d)); int xx, yy; cin >> xx >> yy; int 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 (d[i] < x){ auto itr = lower_bound(ALL(d), x - d[i]); if (itr == d.end()) continue; if (*itr <= x + d[i]){ cout << 2 << endl; return 0; } }else{ auto itr = lower_bound(ALL(d), d[i] - x); if (itr == d.end()) continue; if (*itr <= x + d[i]){ cout << 2 << endl; return 0; } } } cout << -1 << endl; return 0; }