use std::collections::{BTreeSet, BTreeMap}; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut points = (1..n).collect::>(); let mut amap = BTreeMap::new(); for i in 0..n-1 { amap.entry(a[i]).or_insert(vec![]).push(i); } let mut result = vec![0usize; n-1]; for (&span, ps) in amap.iter().rev() { for i in 0..ps.len() { let nextp = points.range(span..).nth(0); if let Some(&np) = nextp { result[ps[i]] = np - span; points.remove(&np); } else { println!("NO"); return; } } } println!("YES"); for &v in result.iter() { println!("{}", v + 1); } }