#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main(){
	int n;
	cin>>n;
	while (n--)
	{
	    int t;
		 scanf("%d",&t);
		 a[t]++;
	 } 
	 int max=1;
	for (int i=0;i<100001-2;i++)
	   if (max<a[i]+a[i+1]+a[i+2])
	      max=a[i]+a[i+1]+a[i+2];
    cout<<max<<endl;

   return 0;
}
