from bisect import bisect def main(): N = int(input()) D = tuple(map(int, input().split())) X, Y = map(int, input().split()) p = abs(X) + abs(Y) if N == 1: if p % D[0]: print(-1) else: print(p // D[0]) return n = 1 while 1: prev = p if p in D: print(n) break x = bisect(D, p) p = abs(p - min(D[x-1], D[x])) if p > prev: print(-1) break n += 1 main()