from bisect import bisect,bisect_left N=int(input()) D=sorted(map(int,input().split())) x,y=map(int,input().split()) ODD=[] EVEN=[] for d in D: if d%2==0: EVEN.append(d) else: ODD.append(d) if x==0 and y==0: print(0) exit() Distance=abs(x)+abs(y) if Distance in D: print(1) exit() for d in D: if d<=Distance: L,R=Distance-d,Distance+d else: L,R=d-Distance,Distance+d if L%2==0: x0=bisect(EVEN,L-1) x1=bisect(EVEN,R) else: x0=bisect(ODD,L-1) x1=bisect(ODD,R) if x0!=x1: print(2) exit() print(-1)