#include<bits/stdc++.h>
using namespace std;
const int N = 3*1e5+5;
int a[N]; 

int main(){
	int n;
	cin >> n;
	memset(a,0,sizeof(a));
	int m,k=0;		
	while(n--) {		
		cin >> m;
		if(k<m) k=m;
		a[m-1]++;
		a[m]++;
		a[m+1]++;
	}
	int M=-1;
	for(int i=0;i<=k;i++)
		M=max(M,a[i]);	
	cout << M << endl;
	return 0;
}
