/* Don't overcomplicate. */ /* Don't construct unnecessary objects. */ /* Stack is for everything. */ #include using namespace std; #define MAX(T) (std::numeric_limits::max()) using i8 = int_fast8_t; using i16 = int_fast16_t; using i32 = int_fast32_t; using i64 = int_fast64_t; using u8 = uint_fast8_t; using u16 = uint_fast16_t; using u32 = uint_fast32_t; using u64 = uint_fast64_t; using st = size_t; const std::string nl = "\n"; #define pb push_back #define eb emplace_back #define forn(n) fornn(_Temp_I_ ## __LINE__ ## __COUNTER__ ## _ ## __FILE__, (n)) #define fornn(name, n) for (size_t name{}; name < n; ++name) #define what_is(x) (std::cerr << (#x) << " is " << (x) << std::endl) int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(nullptr); // disables automatic flush of std::cout before std::cin -- take care in interactive problems //std::ifstream cin("TASKNAME.in"); //std::ofstream cout("TASKNAME.out"); //std::cin.rdbuf(cin.rdbuf()); //std::cout.rdbuf(cout.rdbuf()); /*************** GOOD LUCK ***************/ st n; cin >> n; vector cnt(100); st x; for (st i = 0 ;i < n; i++) { cin >> x; cnt[x-1]++; } st m = 0; for (st i = 0; i < 99; i++) { if (m < cnt[i] + cnt[i+1]) m = cnt[i] + cnt[i+1]; } cout << m << nl; }