N=int(input()) D=sorted(map(int,input().split())) x,y=map(int,input().split()) ODD=0 EVEN=0 for d in D: if d%2==0: EVEN=d else: ODD=d if x==0 and y==0: print(0) exit() Distance=abs(x)+abs(y) if Distance in D: print(1) exit() S=set(D) for d in D: x=Distance-d if x>=0: if (x%2==ODD%2 and x<=ODD) or (x%2==EVEN%2 and x<=EVEN): print(2) exit() else: if -x in S: print(2) exit() print(-1)