#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        int b[100010],c[100010],m = -1;
        memset(c, 0, sizeof(c));
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&b[i]); c[b[i]] ++;
            m = max(m, b[i]);
        }
        int ans = 0;
        for(int i=0; i<=m; i++)
            ans = max(ans, c[i]+c[i+1]+c[i+2]);
        cout << ans << endl;
    }
    return 0;
}
