#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n; cin>>n;
	int a[100010]={};
	rep(i,n){
		int b; cin>>b;
		a[b-1]++; a[b]++; a[b+1]++;
	}
	int ans=0;
	rep(i,100010){
		if(a[i]>ans) ans=a[i];
	}
	cout<<ans<<endl;
	return 0;
}
