#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "< P; int n; int d[125252]; int ne, no; int deven[125252], dodd[125252]; int x,y; int main(){ scanf("%d",&n); REP(i,n)scanf("%d",d+i); scanf("%d%d",&x,&y); x = abs(x); y = abs(y); if(x==0 && y==0){ puts("0"); return 0; } // check once int dist = x+y; REP(i,n)if(dist == d[i]){ puts("1"); return 0; } // check double sort(d,d+n); ne = 0; no = 0; REP(i,n){ if(d[i]%2==0){ deven[ne++] = d[i]; }else{ dodd[no++] = d[i]; } } const int INF = 1252183025; deven[ne] = dodd[no] = INF; REP(i,n){ int s = d[i]; int t; if((x+y)%2==s%2){ // even t = *lower_bound(deven, deven+ne, -x-y+s); }else{ // odd t = *lower_bound(dodd, dodd+no, -x-y+s); } if(t != INF && t <= s){ puts("2"); return 0; } } puts("-1"); return 0; }