#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
using namespace std;

int n, a, c[100009], cnt;
int main() {
    cin >> n;
    rep(i, 0, n) {
        cin >> a;
        c[a]++;
    }
    rep(i, 0, 100001) {
        cnt = max(cnt, c[i] + c[i + 1] + c[i + 2]);
    }
    cout << cnt << endl;
}