#include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template constexpr T INF = ::numeric_limits::max() / 32 * 15 + 208; template vector make_v(U size, const T& init){ return vector(static_cast(size), init); } template auto make_v(U size, Ts... rest) { return vector(static_cast(size), make_v(rest...)); } template void chmin(T &a, const T &b){ a = (a < b ? a : b); } template void chmax(T &a, const T &b){ a = (a > b ? a : b); } int main() { int n; cin >> n; map cnt; vector v(n); for (int i = 0; i < n; ++i) { int x; cin >> x; cnt[x]++; v[i] = x; } int ans = 0; for (auto &&i : v) { int val = 0; for (int j = 0; j < 3; ++j) { val += cnt[i+j]; } ans = max(ans, val); } cout << ans << "\n"; return 0; }