#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int sum[100001];
 int main()
 {  int n;
    while(scanf("%d",&n)!=EOF)
    {int a;
     memset(sum,0,sizeof(sum));
     for(int i=1;i<=n;i++)
     {scanf("%d",&a);
      sum[a+1]++;
      sum[a-1]++;
      sum[a]++;
	 }
	 sort(sum,sum+100001);
	 printf("%d\n",sum[100000]);
	}return 0;
 }