#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
const int maxn = 100000+10;
int main(){
	long n,x,mmax=0;
	map<long,long> b;
	cin>>n;
	while(n!=0){
		cin>>x;
		b[x]++;
		if(b[x]>mmax)mmax=b[x];
		b[x-1]++;
		if(b[x-1]>mmax)mmax=b[x-1];
		b[x+1]++;
		if(b[x+1]>mmax)mmax=b[x+1];
		n--;
	}
	cout<<mmax<<endl;
	return 0;
}