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

using namespace std;

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