/**
   Solution by Iskhak
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e6 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    
	int n, k, i, j;
	
	setlocale (LC_ALL,"RUSSIAN");
	
	cin >> n;
	int ar[n];
	int mx=-1;
	
	for ( i = 0; i< n; i ++) {
		cin >> ar[i];
	}
	
	sort(ar,ar+n);
	
	for ( i = 0; i < n ; i ++) {
		for ( j = 0; j < n; j ++){
			if(ar[i] == ar[j] + 1 || ar[i] == ar[j]-1){
				k ++;
			}
		}
		mx=max(mx,k);
		k = 1;
	}
	cout << mx;
	
	return 0;
}
