#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(100000,0);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[x]++;
	}
	int ans = 0;
	for (int i = 1; i < 99999; i++) {
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
	}
	cout << ans << endl;
}