#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll N;
map<ll, ll> C;
ll R;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    for (ll d : {-1, 0, 1}) ++C[a - d];
  }
  for (auto xc : C) R = max(R, xc.second);
  cout << R << endl;
  return 0;
}
