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