#include <cstdio>

#define MAXN 100002
int main(void)
{
	#if DEBUG
	freopen("_in","r",stdin);
	#endif
	int i,N,*bucket,x;
	bucket=new int [MAXN];
	for(i=0;i<MAXN;i++)
		bucket[i]=0;

	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&x);
		bucket[x]++;
		bucket[x-1]++;
		bucket[x+1]++;
	}

	x=-1;
	for(i=0;i<MAXN;i++)
	{
		if(bucket[i]>x)
			x=bucket[i];
	}

	printf("%d\n",x);
	delete [] bucket;
	return 0;

}