import bisect n = int(input()) d = list(map(int, input().split())) x, y = map(int, input().split()) D = abs(x) + abs(y) d_set = set(d) if D in d_set: print(1) else: d_sorted = sorted(d) found = False for d1 in d_sorted: lower = max(D - d1, d1 - D) upper = d1 + D left = bisect.bisect_left(d_sorted, lower) right = bisect.bisect_right(d_sorted, upper) count = right - left if count >= 2: found = True break print(2 if found else -1)