#include<bits/stdc++.h>
using namespace std;
int main(){
	int n , a[100001] ,dp[100001] ,i ,j ,k;
	cin >>n;
	if(n==1){
		cout<<1;
		return 0;
	}
	
	for(i = 0 ; i < n ; i++){
		cin >>a[i];
	}
	
	for(i = 0 ; i <n ;i++){
		dp[i]=0;
	}
	
	sort(a,a+n);
	for(i=0;i<n;i++)
	 //cout<<a[i]<<" ";
	for(i = 0 ; i < n ; i++){
		//cout<<i<<" ";
		for(j = 0. ; j < n; j++){
			if(i < j && a[i]+1 != a[j])
			if(i == 0){
				if(a[j] == a[i]+1 || a[j] == a[i])
				dp[i]++;
			}
			if(i == n-1){
				if(a[j] == a[i]-1 || a[j] == a[i])
				dp[i]++;
			}
			if(i > 0 && i < n-1 ){
				if(a[j] == a[i]+1 || a[j] == a[i]-1 || a[j] == a[i])
				dp[i]++;
			}
			//cout<<dp[i]<<" ";
		}
		//cout<<endl;
	}
	
	sort(dp,dp+n);
	cout<<dp[n-1];
	return 0;
}
