#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
using namespace std;
int n,a[100010],ans=0;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int main()
{
	cin>>n;
	n=read();
	For(i,1,n)
	{
		int x=read();
		a[x]++;a[x+1]++;a[x+2]++;
	}
	For(i,0,100005)ans=max(ans,a[i]);
	cout<<ans<<endl;
}