#include <iostream>
#include <algorithm>
using namespace std;

int a[100009], b[100009], n, maxn = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[a[i] + 3]++;
	}
	for (int i = 3; i <= 100003; i++) {
		maxn = max(maxn, b[i - 1] + b[i] + b[i + 1]);
	}
	cout << maxn << endl;
	return 0;
}