import bisect def main(): import sys input = sys.stdin.read().split() idx = 0 n = int(input[idx]) idx += 1 d = list(map(int, input[idx:idx+n])) idx += n x = int(input[idx]) y = int(input[idx+1]) D = abs(x) + abs(y) s = x + y if D == 0: print(0) return d_set = set(d) if D in d_set: print(1) return d_sorted = sorted(d) even_d = [] odd_d = [] for num in d_sorted: if num % 2 == 0: even_d.append(num) else: odd_d.append(num) possible = False for di in d_sorted: si = s - di required_parity = abs(si) % 2 low = max(D - di, di - D, abs(si)) high = di + D if low > high: continue if required_parity == 0: lst = even_d else: lst = odd_d if not lst: continue left = bisect.bisect_left(lst, low) right = bisect.bisect_right(lst, high) if left < right: possible = True break print(2 if possible else -1) if __name__ == "__main__": main()