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 long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); TreeSet set = new TreeSet(); for(int i = 0; i < n; i++){ set.add(sc.nextLong()); } ArrayList arr = new ArrayList<>(set); 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 : arr){ if(d == s){ System.out.println(1); return; } } /* for(int i = 0; i < arr.size(); i++){ final long s = arr.get(i); { // d = s1 + s2 final long rest = Math.abs(d - s); final int pos = Collections.binarySearch(arr, rest); if(pos >= 0){ System.out.println(2); return; } } { // d = s1 - s2 final long rest = Math.abs(s - d); final int pos = Collections.binarySearch(arr, rest); if(pos >= 0){ System.out.println(2); return; } } } */ System.out.println(-1); } }