#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int n; ll x, y, d[100005]; int main(void){ cin >> n; ll a[4]; for (int i = 0; i < 4; i++) a[i] = -1000000005; for (int i = 0; i < n; i++) cin >> d[i]; sort(d, d + n); for (int i = n - 1; i >= 0; i--){ if (d[i] % 2 == 0){ for (int j = 0; j < 2; j++){ if (a[j] < 0){ a[j] = d[i]; break; } } } else{ for (int j = 2; j < 4; j++){ if (a[j] < 0){ a[j] = d[i]; break; } } } } cin >> x >> y; ll D = max(x, -x) + max(y, -y); for (int i = 0; i < n; i++){ if (D == d[i]){ cout << 1 << endl; return 0; } } for (int i = 0; i < 4; i++){ for (int j = i + 1; j < 4; j++){ if ((D + a[i] + a[j]) % 2 == 0 && a[i] + a[j] >= D){ if (a[i] == 1 || a[j] == 1){ if (a[i] + a[j] != D + 1)continue; } cout << 2 << endl; return 0; } } } cout << -1 << endl; }