import std.stdio, std.string, std.conv, std.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int n; scan(n); auto d = readln.split.to!(int[]); int x, y; scan(x, y); long L = abs(x) + abs(y); if (L == 0) { writeln(0); return; } foreach (i ; 0 .. n) { if (d[i] == L) { writeln(1); return; } } d.sort(); auto ev = new int[](0); auto od = new int[](0); foreach (i ; 0 .. n) { if (d[i] & 1) od ~= d[i]; else ev ~= d[i]; } debug { writeln(ev); writeln(od); } foreach (i ; 0 .. n) { long ue = L + d[i], sita; if (d[i] <= L) { sita = L - d[i]; } else { sita = d[i] - L; } if (ue & 1) { auto seg = od.assumeSorted.lowerBound(ue + 1); auto segs = seg.assumeSorted.upperBound(sita -1); if (!segs.empty) { writeln(2); return; } } else { auto seg = ev.assumeSorted.lowerBound(ue+1); auto segs = seg.assumeSorted.upperBound(sita-1); if (!segs.empty) { writeln(2); return; } } } writeln(-1); } 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); } } }