import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = 18446744073709551615 inf = 4294967295 md = 10**9+7 # md = 998244353 from bisect import * def solve(): n = II() dd = LI() dd.sort() x, y = LI() x, y = abs(x+y), abs(x-y) if x < y: x, y = y, x if x == 0: print(0) return if x in dd: print(1) return dd0, dd1 = [], [] for d in dd: if d & 1: dd1.append(d) else: dd0.append(d) mx0 = mx1 = -1 if dd0: mx0 = max(dd0) if dd1: mx1 = max(dd1) if x%2 == 0: if x <= mx1*2 or x <= mx0*2: print(2) else: print(-1) return if dd0 and dd1: for d0 in dd0: i = bisect_left(dd1, abs(x-d0)) if i < len(dd1) and dd1[i] <= x+d0: print(2) return print(-1) solve()