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

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