import java.util.ArrayDeque; import java.util.Arrays; import java.util.Queue; import java.util.Scanner; import java.util.TreeSet; public class HiddenGame { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); int[] d = new int[N]; for(int i = 0;i < N;i++){ d[i] = s.nextInt(); } Arrays.sort(d); int goalx = s.nextInt(),goaly = s.nextInt(); s.close(); int goal = Integer.max(Math.abs(goalx), Math.abs(goaly)); int count = 0; if(goal/d[N-1] > 10000000){ count = goal/d[N-1]-2; goal = goal%d[N-1]+2; } TreeSet T1 = new TreeSet<>(); TreeSet T2 = new TreeSet<>(); Queue REST = new ArrayDeque<>(); REST.add(goal); for(;;){ int rest = REST.poll(); if(rest == 0){ break; }else if(rest < d[0]){ count +=2; break; } T1.clear(); for(int i : d){ T1.add(Math.abs(rest-i)); } for(int i:T1){ for(int j:d){ T2.add(Math.abs(i-j)); } } if(T2.contains(0)){ count += 2; break; }else if(T1.contains(0)){ count += 1; break; }else if(T1.first() == T2.first()){ count = -1; } REST.clear(); REST.addAll(T1); T1 = new TreeSet(T2); T2.clear(); count++; } System.out.println(count); } }