#include<bits/stdc++.h>
using namespace std;
int n,x,a[1000000],ans;
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;
}
int main(){
	n=read();for (int i=1;i<=n;i++)x=read(),a[x]++,a[x+1]++,a[x+2]++;
	ans=0;for (int i=0;i<=200000;i++)ans=max(ans,a[i]);cout<<ans<<endl;
}
