#include <bits/stdc++.h>
using namespace std;
int a[200000];
int main() {
  int x, y, z, i, n, m, j, k, l;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + 1 + n);
  x = 0;
  y = 1;
  l = a[1];
  for (i = 1; i <= n; i++) {
    if (a[i] - l <= 2) {
      x++;
      y = max(x, y);
    } else {
      for (j = i - 1; j >= 1; j--) {
        if (a[i] - a[j] <= 2) {
          i = j;
          l = a[j];
          break;
        }
      }
      y = max(x, y);
      x = 1;
    }
  }
  printf("%d", y);
  return 0;
}
