from bisect import bisect_left def main(): N = int(input()) D = tuple(map(int, input().split())) X, Y = map(int, input().split()) goal = abs(X) + abs(Y) if goal == 0: print(0) elif bisect_left(D, goal) < N: print(1) else: for i in D: if bisect_left(D, abs(goal - i)) < N: print(2) break else: print(-1) main()