#[allow(unused_imports)] use std::cmp::{max, min, Ordering}; #[allow(unused_imports)] use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap}; #[allow(unused_imports)] use std::iter::FromIterator; #[allow(unused_imports)] use std::io::stdin; mod util { use std::io::stdin; use std::str::FromStr; use std::fmt::Debug; #[allow(dead_code)] pub fn line() -> String { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().to_string() } #[allow(dead_code)] pub fn gets() -> Vec where ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse().unwrap()) .collect() } } #[allow(unused_macros)] macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::>() }; ($t:ty ;;) => { { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::>() } }; } #[allow(unused_macros)] macro_rules! debug { ($($a:expr),*) => { println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*); } } fn main() { let n = get!(usize); let ds = get!(i64;;); let (x, y) = get!(i64, i64); let mut heaps = vec![BinaryHeap::new(); 2]; for &d in &ds { heaps[(d % 2) as usize].push(d); } let z = x.abs() + y.abs(); if z == 0 { println!("0"); return; } if ds.iter().any(|&d| d >= z && (d - z) % 2 == 0) { println!("1"); return; } if z % 2 == 0 { if heaps[0].pop().unwrap_or(0) + heaps[0].pop().unwrap_or(0) >= z || heaps[1].pop().unwrap_or(0) + heaps[1].pop().unwrap_or(0) >= z { println!("2"); } else { println!("-1"); } } else { if heaps[0].pop().unwrap_or(0) + heaps[1].pop().unwrap_or(0) >= z { println!("2"); } else { println!("-1"); } } }