#include<bits/stdc++.h>
using namespace std;
int maxx, n;
const int maxn = 100010;
int a[maxn], b[maxn], c[maxn], num = 0, max1, max2;

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		b[i] = a[i] + 1;
		c[i] = a[i] - 1; 
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(a[i] == b[j]){
				num++;
			}
		}
		if(num > max1){
			max1 = num;
		}
		num = 0;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(a[i] == c[j]){
				num++;
			}
		}
		if(num > max2){
			max2 = num;
		}
		num = 0;
	} 
	printf("%d", max1 + max2 + 1);
	return 0;
}