import sys from itertools import combinations readline = sys.stdin.readline n = int(readline()) d = sorted(map(int, readline().split())) x, y = map(int, readline().split()) l = abs(x) + abs(y) def solve(): if l == 0: return 0 elif l in d: return 1 elif l % 2 == 0: -1 if max(d) * 2 >= l else 2 else: d1 = [x for x in d if x % 2 == 0] d2 = [x for x in d if x % 2 == 1] if d1 != []: for a in d2: low = 0 high = len(d1) - 1 while low < high: mid = (high + low) >> 1 if (a + d1[mid] >= l): high = mid else: low = mid + 1 if (a + d1[low] < l): continue b = low low = 0 high = len(d1) - 1 while low < high: mid = (high + low + 1) >> 1 if (a > d1[mid] or abs(a - d1[mid]) <= l): low = mid else: high = mid - 1 if (abs(a - d1[low]) > l): continue c = low if (b <= c): return 2 return -1 print(solve())