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]; for(int i = 0; i < n; i++){ array[i] = sc.nextLong(); } TreeSet odds = new TreeSet(); TreeSet evens = new TreeSet(); for(int i = 0; i < n; i++){ if(array[i] % 2 == 0){ evens.add(array[i]); }else{ odds.add(array[i]); } } System.out.println(odds); System.out.println(evens); 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; } if(d % 2 == 0){ // (odd, odd) or (even, even) if(evens.ceiling(d) != null){ System.out.println(1); return; } for(final long s : evens){ final long diff = Math.abs(d - s); if(evens.ceiling(diff) != null){ System.out.println(2); return; } } for(final long s : odds){ final long diff = Math.abs(d - s); if(odds.ceiling(diff) != null){ System.out.println(2); return; } } }else{ // (odd, even) or (even, odd) if(odds.ceiling(d) != null){ System.out.println(1); return; } for(final long s : evens){ final long diff = Math.abs(d - s); if(odds.ceiling(diff) != null){ System.out.println(2); return; } } for(final long s : odds){ final long diff = Math.abs(d - s); if(evens.ceiling(diff) != null){ System.out.println(2); return; } } } System.out.println(-1); } }