#include<bits/stdc++.h>
using namespace std;
int a[1000005],b[1000005],c[1000005],d[1000005];

int main()
{
	int n,i,x=0;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		d[a[i]]++;
		b[i]=a[i]+1;
		d[b[i]]++;
		c[i]=a[i]-1;
		d[c[i]]++;
	}
	int cnt=0;
	for(i=0;i<1000005;i++){
		if(d[i]>cnt){
			cnt=d[i];
		}
	}
	cout << cnt << endl;
	return 0;
}