use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace().map(|w| w.parse::().unwrap()); let n: usize = iter.next().unwrap() as usize; let half: isize = iter.clone().sum(); let mut weights: Vec = iter.collect(); weights.sort(); println!("{}", brute_force(0, half, &weights, n)); } fn brute_force(pos: usize, remaining: isize, weights: &Vec, n: usize) -> bool { if remaining == 0 { return true } else if remaining < 0 || pos == n { return false } brute_force(pos + 1, remaining - weights[pos], weights, n) || brute_force(pos + 1, remaining, weights, n) }