#include using namespace std; typedef long long ll; typedef double ld; typedef pair pl; #define sl(x) scanf("%d",&x) #define pl(x) printf("%lld\n",x) #define sf(x) sort(x.begin(),x.end(),func) #define s(x) sort(x.begin(),x.end()) #define all(v) v.begin(),v.end() #define rs(v) { s(v) ; r(v) ; } #define r(v) {reverse(all(v));} #define pb push_back #define mp make_pair #define F first #define S second #define f(i,n) for(int i=0;i= m) a -= m; if(a < 0) a += m; return a;} ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;} ll n, a[N]; int main() { ios_base::sync_with_stdio(0); cin >> n; map < ll , ll > m; f(i, n) cin >> a[i]; f(i, n) m[a[i]]++; sort(a, a + n); ll ans = 0; for(auto it = m.begin(); it != m.end(); it++) { ll no = it -> F; ll xx = it -> S; no++; if(m.find(no) != m.end()) { ans = max(ans, xx + m[no]); } ans = max(ans, xx); } cout << ans << "\n"; return 0; }