import sys readline = sys.stdin.readline n = int(readline()) pq = [[], []] for i in map(int, readline().split()): pq[i % 2].append(i) x, y = map(int, readline().split()) z = abs(x) + abs(y) def solve(): if z == 0: return 0 if z in pq[0] or z in pq[1]: return 1 pq[0].sort() pq[1].sort() if z % 2 == 0: if pq[0]: if pq[0][-1] * 2 >= z: return 2 if pq[1]: if pq[1][-1] * 2 >= z: return 2 else: while pq[0] and pq[1]: t1 = pq[0][-1] t2 = pq[1][-1] if t1 + t2 >= z and max(t1, t2) - min(t1, t2) <= z: return 2 if t1 > t2: pq[0].pop() else: pq[1].pop() return -1 print(solve())