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

int main()
{
	
	int n,max = 0;
	memset(b,0,sizeof(b));	
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++){
		cin >> a[i];
		
		if(max < a[i])
		max = a[i];
		b[a[i]]++;
		b[a[i]-1]++;
		b[a[i]+1]++;
	
	}
	int max1 = 0;
	
	for(int i = 0;i <= max + 1;i++){
		if(max1<b[i])
			max1 = b[i];
	}
	cout << max1;
	return 0;
}
