#include <bits/stdc++.h>
using namespace std;
int sc1() {
  int x;
  scanf("%d", &x);
  return x;
}
long long sc2() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int main() {
  int n = sc1();
  std::vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int pp = v[i] + 5;
    std::vector<int>::iterator up;
    up = std::upper_bound(v.begin(), v.end(), pp);
    int x = up - v.begin();
    x = x - (i + 1);
    ans = max(ans, x);
  }
  cout << ++ans << endl;
  return 0;
}
