#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans = 0;
vector<int> vec, v;
int main() {
  int a, b, c;
  cin >> n;
  for (long long i = (0); i < (n); i++) {
    cin >> a;
    vec.push_back(a);
  }
  if (n == 1) {
    cout << "1" << endl;
    return 0;
  }
  sort((vec).begin(), (vec).end());
  for (long long i = (0); i < (vec.size() - 1); i++) {
    b = vec[i];
    c = 0;
    for (long long j = (i + 1); j < (vec.size()); j++) {
      if (!(b == vec[j] || b + 1 == vec[j] || b + 2 == vec[j])) {
        c = j - i;
        if (ans < c) ans = c;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
