#include<bits/stdc++.h>
#include<ctime>
#include<random>
using namespace std;

int n;
map<int, int> mp;
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		mp[a]++;
		mp[a - 1]++;
		mp[a + 1]++;
	}
	int ans = 0;
	for (auto it : mp){
		ans = max(ans, it.second);
	}
	cout << ans << endl;
	return 0;
}