#include <iostream>

using namespace std;
int a[100002] = {0};
int main()
{
    int n;
    scanf("%d", &n);
    int val[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &val[i]);
        a[val[i] + 1]++;
    }
    int m = 0;
    for(int i = 0; i < n; i++){
        m = max(m, a[val[i] + 1] + a[val[i] + 2] + a[val[i]]);
    }
    printf("%d", m);
    return 0;
}
