#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,cnt[100005],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		cnt[a]++,ans=max(ans,cnt[a]);
		cnt[a+1]++,ans=max(ans,cnt[a+1]);
		if(a-1>=0) cnt[a-1]++,ans=max(ans,cnt[a-1]);
	}
	printf("%d\n",ans);
	return 0;
}