#include<iostream>

using namespace std;

int C[200000];

int main()
{
  int N, a;
  cin >> N;

  for(int i = 0; i < N; i++) {
    cin >> a;
    C[a]++;
    C[a + 1]++;
    C[a + 2]++;
  }

  int max = 0;
  for(int i = 0; i < 200000; i++) {
    if(max < C[i]) {
      max = C[i];
    }
  }
  cout << max << endl;

  return 0;
}