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