#include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;
int a[500001],b[500002]={0};
int main(){
	int n;
	cin>>n;
	int i;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]-1<0){
			b[500001]++;
		}else{
			b[a[i]-1]++;
		}
		b[a[i]]++;
		b[a[i]+1]++;
	}
	int max=0;
	for(i=0;i<=500001;i++){
		if(b[i]>max){
			max=b[i];
		}
	}
	cout<<max<<endl;
	return 0;
}