#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{    
	 int j,k,n,i;int a[100000],b[100000],c[100000],cout[100000],max=0;
	 scanf("%d",&n);
	 memset(a,0,sizeof(a));
	 memset(b,0,sizeof(b));
	 memset(c,0,sizeof(c));
	 memset(cout,0,sizeof(cout));
	 for(i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	 for(i=1;i<=n;i++)  
	  { b[i]=a[i]-1;
	    c[i]=a[i]+1;
      }
      for(i=1;i<=n;i++)
    {if(a[i]==0||b[i]==0||c[i]==0)  cout[0]++;
     if(a[i]==1||b[i]==1||c[i]==1)  cout[1]++;
     if(a[i]==2||b[i]==2||c[i]==2)  cout[2]++;
     if(a[i]==3||b[i]==3||c[i]==3)  cout[3]++;
     if(a[i]==4||b[i]==4||c[i]==4)  cout[4]++;
     if(a[i]==5||b[i]==5||c[i]==5)  cout[5]++;
     if(a[i]==6||b[i]==6||c[i]==6)  cout[6]++;
     if(a[i]==7||b[i]==7||c[i]==7)  cout[7]++;
     if(a[i]==8||b[i]==8||c[i]==8)  cout[8]++;
     if(a[i]==9||b[i]==9||c[i]==9)  cout[9]++;
     if(a[i]==10||b[i]==10||c[i]==10)  cout[10]++;
 	 }  
	 for(i=0;i<=10;i++)
	 { if(cout[i]>max) max=cout[i];}	 
	 printf("%d",max); 
}
