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

int main()
{
	
	int n;
	memset(a,0,sizeof(a));
	int ai;	
	cin >> n;
	int max = 0;
	while(n--){
		cin >> ai;
		
		if(max < ai){

		a[ai]++;
		a[ai-1]++;
		a[ai+1]++;

			}	
	}
	int max1 = 0;
	
	for(int i = 0;i <= max + 1;i++){
		if(max1<a[i])
			max1 = a[i];
	}
	cout << max1+1 << endl;
}
