#[allow(unused_macros)] macro_rules! getl { ( $( $t:ty ),* ) => { { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let s = s.trim_end(); let mut ws = s.split_whitespace(); ($(ws.next().unwrap().parse::<$t>().unwrap()),*) } }; } #[allow(unused_macros)] macro_rules! getl_vec { ( $t:ty ) => {{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let s = s.trim_end(); s.split_whitespace() .map(|x| x.parse().unwrap()) .collect::>() }}; } fn main() { let n = getl!(usize); let a = getl_vec!(usize); let mut b = a.clone(); b.sort(); let mut v = vec![vec![]; n]; for i in 2..=n { let bi = b[i - 2]; if bi > i - 1 { println!("NO"); return; } v[bi].push(i - bi); } println!("YES"); for ai in a { let c = v[ai].pop().unwrap(); println!("{}", c); } }