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