import sys n = int(input()) d_arr = list(map(int, input().split())) x, y = map(lambda n: abs(int(n)), input().split()) if x == 0 and y == 0: print(0) sys.exit() for d in d_arr: if d == x + y: print(1) sys.exit() odd = 0 even = 0 for d in d_arr: if d % 2 == 0: even += 1 else: odd += 1 if even >= 2 or odd >= 2: print(2) sys.exit() print(-1)