#include using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; set s; for (int i = 0; i < n; i++) { ll d; cin >> d; s.insert(d); } ll x, y; cin >> x >> y; ll dist = abs(x) + abs(y); int ans = -1; if (dist == 0) { ans = 0; } else if (s.find(dist) != s.end()) { ans = 1; } else { for (ll v : s) { if (s.find(dist - v) != s.end()) ans = 2; if (s.find(v + dist) != s.end()) ans = 2; } set s2, s3; for (ll v : s) { if (v >= abs(x)) s2.insert(v - abs(x)); if (v >= abs(y)) s3.insert(v - abs(y)); } for (ll v : s2) { if (s3.find(v) != s3.end()) ans = 2; } } cout << ans << endl; return 0; }