#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long int ll;
const ll N = 100000;
ll d[N],n,cp;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)scanf("%d", d + i);
	sort(d , d + n);
	ll x, y; cin >> x >> y;
	cp = abs(x) + abs(y);
	if (cp == 0) { cout << 0 << endl; goto end; }
	if (find(d, d + n, cp) - d < n) { cout << 1 << endl; goto end; }
	for (int i = 0; i < n; i++) {
		ll lb = abs(cp - d[i]), ub = (cp + d[i]);
		for (int j = lower_bound(d, d + n, lb) - d; j<n&&d[j] <= ub; j++) {
			if (d[j] % 2 == ub % 2) { cout << 2 << endl; goto end; }
		}
	}
	cout << -1 << endl;
end:;
	return 0;
}