#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N, D[101010], X, Y; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; rep(i, 0, N) cin >> D[i]; sort(D, D + N); cin >> X >> Y; if (X == 0 and Y == 0) { printf("0\n"); return; } rep(i, 0, N) if (D[i] == abs(X) + abs(Y)) { printf("1\n"); return; } int dx = abs(X - Y); int dy = abs(X + Y); int ma = max(dx, dy); if (ma <= D[N - 1] * 2) printf("2\n"); else printf("-1\n"); }