use std::io::{BufRead, BufReader, BufWriter, Write}; use std::{str::FromStr, iter::FromIterator, fmt::Display}; pub struct ProconIo<'a> { pub reader: BufReader>, pub writer: BufWriter>, } impl ProconIo<'_> { pub fn get_input(&mut self) -> String { let mut input = String::new(); self.reader.read_line(&mut input).ok(); input } pub fn read(&mut self) -> T { self.get_input().trim().parse().ok().unwrap() } pub fn read_col>(&mut self) -> C { self.get_input() .split_whitespace() .map(|x| x.parse().ok().unwrap()) .collect() } pub fn read_chars>(&mut self) -> C { self.get_input().trim().chars().collect() } pub fn writeln(&mut self, x: T) { writeln!(self.writer, "{}", x).ok(); } pub fn writeln_col(&mut self, c: C) where C::Item: Display, { self.writeln( c.into_iter() .map(|x| x.to_string()) .collect::>() .join(" ") ) } } #[allow(unused_macros)] macro_rules! read_tuple { ( $io:expr, $( $t:ty ),* ) => {{ let input = $io.get_input(); let mut iter = input.split_whitespace(); ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* ) }}; } fn solve(io: &mut ProconIo) { let n: usize = io.read(); let mut a: Vec = (0..n).map(|_| io.read()).collect(); a.sort(); let mut set = std::collections::BTreeSet::new(); for a in a.into_iter().rev() { if let Some(&val) = set.range((a + 2)..).next() { set.remove(&val); } set.insert(a); } io.writeln(set.len()); } fn main() { let stdin = std::io::stdin(); let stdout = std::io::stdout(); let mut io = ProconIo { reader: BufReader::new(stdin.lock()), writer: BufWriter::new(stdout.lock()), }; solve(&mut io); }