#[macro_export] macro_rules! setup { { mut $input:ident: SplitWhitespace $(,)? } => { use std::io::Read; let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut $input = buf.split_whitespace(); }; } #[macro_export] macro_rules! parse_next { ($str_iter:expr) => { $str_iter.next().unwrap().parse().unwrap() }; } fn main() { setup! { mut input: SplitWhitespace }; let n: usize = parse_next!(input); let mut a: Vec = (0..n).map(|_| parse_next!(input)).collect(); a.sort(); let mut count = 0; while !a.is_empty() { let mut idxs = vec![0]; let mut size = a[0]; for i in 1..a.len() { if size + 1 < a[i] { idxs.push(i); size = a[i]; } } idxs.reverse(); for idx in idxs.into_iter() { a.remove(idx); } count += 1; } println!("{}", count); }