#include<bits/stdc++.h>
using namespace std;
int a[111111];
int main(){
	int n,x;
	for(scanf("%d",&n); n--;){
		scanf("%d",&x);
		a[x+1] ++;
	}
	int res  = 0;
	for(int i=1; i<=100000; i++){
		int now = a[i-1] + a[i] + a[i+1];
		if(now > res)res = now;
	}
	printf("%d\n",res);
	return 0;
}
