#include <bits/stdc++.h>
using namespace std;
int c[999999],q[999999];
int main() {
	int a,b,w=0,i;
	cin>>a;
	for (i=1;i<=a;++i){
		cin>>c[i];
		q[c[i]]++;
	}
	sort(c+1,c+a+1);
	for (i=1;i<=a;++i){
		w=max(w,q[ c[i] ] + q[ c[i] -1] + q[ c[i]+1]);
	}
	cout <<w;
}