#include <cstdio>
#define maxn (100000+10)
int p[maxn*2];int *cnt=p+maxn;
int a[maxn];

int y,ans,n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		++cnt[a[i]];
		++cnt[a[i]-1];
		++cnt[a[i]+1];
	}
	  
	for (int i=-1;i<maxn;++i)
	  if (cnt[i]>y) y=cnt[i];
	printf("%d",y);
	return 0;
}