use proconio::{fastout, input}; use std::collections::BTreeSet; #[fastout] fn main() { input! { n: usize, a: [i64; n], } let mut set = BTreeSet::new(); let mut t = 0; for i in 0..n { set.insert((a[i], t)); t += 1; } for _ in 0..n - 1 { if let Some(&x) = set.range((0, 0)..).next() { set.remove(&x); if let Some(&y) = set.range(..=(0, i32::MAX)).last() { set.remove(&y); set.insert((x.0 + y.0, t)); t += 1; } else { println!("No"); return; } } else { println!("No"); return; } } println!("Yes"); }