import std.stdio, std.string, std.conv, std.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; immutable long inf = 10^^9 + 7; alias Edge = Tuple!(int, "to", long, "flow", long, "cap", int, "rev"); void main() { int n; scan(n); auto d = readln.split.to!(int[]); int x, y; scan(x, y); int L = abs(x) + abs(y); if (L == 0) { writeln(0); return; } d.sort(); foreach (i ; 0 .. n) { if (d[i] == L) { writeln(1); return; } } foreach (i ; 0 .. n) { int r = L - d[i]; auto ub = d.assumeSorted.lowerBound(r + 1); debug { writeln(ub); } if (!ub.empty && ub.back == r) { writeln(2); return; } } writeln(-1); } long Dinic(Edge[][] adj, int s, int t) { int n = adj.length.to!int; int[] level = new int[](n); int[] prog = new int[](n); auto q = Queue!(int)(n); bool bfs() { level[] = -1; level[s] = 0; q.clear(); q.push(s); while (!q.empty) { auto u = q.front; q.pop; foreach (e ; adj[u]) { if (level[e.to] == -1 && e.cap - e.flow > 0) { level[e.to] = level[u] + 1; q.push(e.to); } } } return level[t] != -1; } long dfs(int u, long f) { if (u == t) return f; for (; prog[u] < adj[u].length; prog[u]++) { auto e = &adj[u][prog[u]]; if (level[u] + 1 == level[e.to] && e.flow < e.cap) { long d = dfs(e.to, min(f, e.cap - e.flow)); if (d > 0) { e.flow += d; adj[e.to][e.rev].flow -= d; return d; } } } return 0; } long F; while (bfs()) { prog[] = 0; while (true) { auto df = dfs(s, inf); if (df) F += df; else break; } } return F; } struct Queue(T) { private { int N, head, tail; T[] data; } this (int n) { N = n + 1; data = new T[](N); } bool empty() { return head == tail; } bool full() { return (tail + 1) % N == head; } T front() { return data[head]; } void push(T x) { assert(!full); data[tail++] = x; tail %= N; } void pop() { assert(!empty); head++; head %= N; } void clear() { head = tail = 0; } } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }