#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100005],b[100005];
int main(){
//	freopen("a.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		++b[a[i]];
	}
	int ans=0;
	for(int i=1;i<=100000;++i){
		ans=max(ans,b[i-1]+b[i]+b[i+1]);
	}
	printf("%d\n",ans);
	return 0;
}