fn main() { let (n, d): (usize, i32) = { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) }; let mut fav = Vec::with_capacity(n); let mut set = std::collections::BTreeSet::new(); for i in 0..n { let a: i32 = { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); buf.trim_end().parse().unwrap() }; fav.push(a); set.insert((a, i)); } for a in fav { println!("{}", set.range(..(a - d, n)).count()); } }