#include<bits/stdc++.h>
using namespace std;
int n,x,ans,f[100005];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		f[x]++;
		f[x+1]++;
		f[x+2]++;
	}
	for (int i=0;i<=100002;i++)
		ans=max(ans,f[i]);
	printf("%d",ans);
}