import sys readline = sys.stdin.readline n = int(readline()) pq = [[], []] d = sorted(map(int, readline().split()), reverse=True) x, y = map(int, readline().split()) z = abs(x) + abs(y) def solve(): if z == 0: return 0 if z in d: return 1 for i in d: pq[i % 2].append(i) if z % 2 == 0: if pq[0]: if pq[0][0] * 2 >= z: return 2 if pq[1]: if pq[1][0] * 2 >= z: return 2 else: while pq[0] and pq[1]: t1 = pq[0][0] t2 = pq[1][0] 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())