#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
	int n, a, count[100001] = { 0 };
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		count[a]++;
	}

	int max_v = 0;
	for (int i = 1; i <= 99999; i++)
		max_v = max(max_v, count[i - 1] + count[i] + count[i + 1]);

	printf("%d\n", max_v);
}