import bisect n = int(input()) d = list(map(int, input().split())) x, y = map(int, input().split()) D = abs(x) + abs(y) if D == 0: print(0) else: sorted_d = sorted(d) idx = bisect.bisect_left(sorted_d, D) if idx < len(sorted_d) and sorted_d[idx] == D: print(1) else: found = False for di in sorted_d: low = max(0, D - di) high = di + D left = bisect.bisect_left(sorted_d, low) right = bisect.bisect_right(sorted_d, high) if left < right: found = True break print(2 if found else -1)