import sys from itertools import combinations readline = sys.stdin.readline n = int(readline()) d = sorted(map(int, readline().split())) x, y = map(int, readline().split()) max_xy = abs(x) + abs(y) def solve(): if max_xy in d: return 1 if len(d) == 1: return -1 if max_xy > d[-1] + d[-2]: return -1 for a, b in combinations(d, 2): if max_xy == a + b or max_xy == abs(a - b): return 2 return -1 print(solve())