import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; long[] d; long x, y; n = sc.nextInt(); d = new long[n]; for (int i = 0; i < n; ++i) d[i] = sc.nextLong(); Arrays.sort(d); x = sc.nextLong(); y = sc.nextLong(); x = Math.abs(x); y = Math.abs(y); System.out.println(solve(n, d, x, y)); } static int solve(int n, long[] d, long x, long y) { if (x < y) { x ^= y; y ^= x; x ^= y; } if (x == 0 && y == 0) { return 0; } for (int i = 0; i < n; ++i) { if (d[i] == x + y) { return 1; } } HashSet set = new HashSet(); for (int i = 0; i < n; ++i) { set.add(d[i]); } for (int i = 0; i < n; ++i) { if (!set.contains(x + y - d[i]) && !set.contains(x + y + d[i])) continue; return 2; } long[] evenD = new long[n]; long[] oddD = new long[n]; int oddp = 0, evenp = 0; for (int i = 0; i < n; ++i) { if (d[i] % 2 == 0) evenD[evenp++] = d[i]; else oddD[oddp++] = d[i]; } evenD = Arrays.copyOf(evenD, evenp); oddD = Arrays.copyOf(oddD, oddp); Arrays.sort(evenD); Arrays.sort(oddD); if ((x - y) % 2 == 0) { if (2 * Math.max(evenD.length > 0 ? evenD[evenD.length - 1] : 0, oddD.length > 0 ? oddD[oddD.length - 1] : 0) >= x + y) { return 2; } } else if (evenD.length > 0 && oddD.length > 0) { for (int t = 0; t < 2; ++t) { int p1 = 0, p2 = 0; for (p1 = 0; p1 < evenD.length; ++p1) { while (p2 + 1 < oddD.length && (evenD[p1] + oddD[p2] < x + y || x + y < evenD[p1] - oddD[p2])) ++p2; if (evenD[p1] + oddD[p2] >= x + y && x + y >= evenD[p1] - oddD[p2] && evenD[p1] - oddD[p2] >= Math.min(x, y) - Math.max(x, y)) { return 2; } } long[] tmp = Arrays.copyOf(evenD, evenD.length); evenD = oddD; oddD = tmp; } } return -1; } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }