import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.Scanner; import java.util.TreeSet; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); long[] array = new long[n]; long odd_max = 0, even_max = 0; for(int i = 0; i < n; i++){ array[i] = sc.nextLong(); if(array[i] % 2 == 0){ even_max = Math.max(even_max, array[i]); }else{ odd_max = Math.max(odd_max, array[i]); } } final long d_odd_max = even_max + odd_max; final long d_even_max = Math.max(odd_max * 2, even_max * 2); final long x = sc.nextLong(); final long y = sc.nextLong(); final long d = Math.abs(x) + Math.abs(y); if(d == 0){ System.out.println(0); return; } for(final long s : array){ if(s == d){ System.out.println(1); return; } } if(d % 2 == 0 && d <= d_even_max - 2){ System.out.println(2); return; } if(d % 2 == 1 && d <= d_odd_max - 2){ System.out.println(2); return; } System.out.println(-1); } }