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(); x = sc.nextLong(); y = sc.nextLong(); System.out.println(solve(n, d, x, y)); } static int solve(int n, long[] d, long x, long y) { x = Math.abs(x); y = Math.abs(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 maxoddD = 0, maxevenD = 0; for (int i = 0; i < n; ++i) { if (d[i] % 2 == 0) maxevenD = Math.max(maxevenD, d[i]); else maxoddD = Math.max(maxoddD, d[i]); } if ((x - y) % 2 == 0) { if (2 * Math.max(maxevenD, maxoddD) >= x + y) { return 2; } } return -1; } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }