#include <bits/stdc++.h>
int main(void) {
  int N = 0;
  int A[100005] = {0};
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int a = 0;
    scanf("%d", &a);
    if (a != 0) A[a - 1]++;
    A[a]++;
    A[a + 1]++;
  }
  int max = 0;
  for (int i = 0; i < 100000; i++) {
    max = max < A[i] ? A[i] : max;
  }
  printf("%d\n", max);
  return 0;
}
