#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from bisect import bisect_left, bisect_right N = int(readline()) D = tuple(map(int, readline().split())) x, y = map(int, read().split()) x = abs(x) y = abs(y) def dist_range(d): if d > x + y: return d - x - y, d + x + y else: return x + y - d, d + x + y D_od = [x for x in D if x & 1] D_ev = [x for x in D if not (x & 1)] D_od.sort() D_ev.sort() def solve(): if x == y == 0: return 0 if x + y in D: return 1 for d in D: d1, d2 = dist_range(d) A = D_od if d1 & 1 else D_ev if bisect_right(A, d2) - bisect_left(A, d1): return 2 return - 1 print(solve())