#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n;
  int a[100005];
  int b[100005];
  int c[100005];
  int ans[100005];
  memset(ans, 0, sizeof(ans));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i] - 1;
    c[i] = a[i] + 1;
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    ans[a[i]]++;
    ans[b[i]]++;
    ans[c[i]]++;
  }
  sort(ans, ans + 100005, cmp);
  printf("%d", ans[0]);
  return 0;
}
