#include #include #include using namespace std; int main(){ int n; cin >> n; int move_mass[n]; vector even_odd[2]; int number_max = 0; for(int i = 0; i < n; i++){ cin >> move_mass[i]; number_max = max(number_max, move_mass[i]); even_odd[move_mass[i] % 2].push_back(move_mass[i]); } int x, y; cin >> x >> y; int distance = abs(x) + abs(y); if(!distance){ cout << 0 << endl; } sort(move_mass, move_mass + n); sort(even_odd[0].begin(), even_odd[0].end()); sort(even_odd[1].begin(), even_odd[1].end()); for(int i = 0; i < n; i++){ if(move_mass[i] == distance){ cout << 1 << endl; return 0; } } int min_difference = 0; int look_not_odd = 0; int look_odd = 0; while(look_not_odd != even_odd[0].size() && look_odd != even_odd[1].size()){ min_difference = min(min_difference, abs(even_odd[0][look_not_odd] - even_odd[1][look_odd])); if(even_odd[0][look_not_odd] > even_odd[1][look_odd]){ look_odd++; }else{ look_not_odd++; } } if(distance % 2 == 0){ if(max(even_odd[0].back(), even_odd[1].back()) * 2 >= distance){ cout << 2 << endl; }else{ cout << -1 << endl; } }else if(even_odd[0].size() && even_odd[1].size()){ if(min_difference <= distance && distance <= even_odd[0].back() + even_odd[1].back()){ cout << 2 << endl; }else{ cout << -1 << endl; } }else{ cout << -1 << endl; } }