#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,x;
    int a[100100];
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        a[x]++;
    }
    int maximum=a[0]+a[1],c;
    for(int i=1;i<100005;i++){
        c=a[i]+a[i+1]+a[i-1];
        maximum=(maximum>c?maximum:c);
    }
    printf("%d\n",maximum);
    return 0;
}