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()); iter.next().unwrap(); let weights = iter; let mut remaining: usize = weights.clone().sum(); if remaining % 2 == 1 { println!("impossible"); return } let half: usize = remaining / 2; let mut sums: Vec = vec![0]; for weight in weights { let mut new_sums: Vec = Vec::new(); remaining -= weight; for sum in sums.into_iter() { let new_sum: usize = sum + weight; if new_sum <= half { new_sums.push(new_sum); } if remaining + sum >= half { new_sums.push(sum); } } new_sums.sort(); new_sums.dedup(); sums = new_sums; } println!("{}", if sums.contains(&half) {"possible"} else {"impossible"}); }