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

int main()
{
	int n,x,maks=0;
	cin >> n;
	map<int, int> m;
	for (int i=0;i<n;++i)
	{
		cin >> x;
		++m[x];
		++m[x-1];
		++m[x+1];
		if (m[x]>maks) maks = m[x];
		if (m[x-1]>maks) maks = m[x-1];
		if (m[x+1]>maks) maks = m[x+1];
	}
	cout << maks << endl;
	return 0;
}