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()); } final long x = sc.nextLong(); final long y = sc.nextLong(); final long d = Math.abs(x) + Math.abs(y); ArrayList arr = new ArrayList<>(set); 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); if(d > s){ final long rest = d - s; final long pos = Collections.binarySearch(arr, rest); if(pos >= 0){ System.out.println(2); return; } }else{ final long rest = s - d; final long pos = Collections.binarySearch(arr, rest); if(pos >= 0){ System.out.println(2); return; } } } System.out.println(-1); } }