#include <bits/stdc++.h>
using namespace std;
const long MAXS = 1000000;
const long MOD = 1000000007;
const double PI = 3.1415926535;
int main() {
  ios_base::sync_with_stdio(0);
  setlocale(LC_ALL, "");
  long n, t;
  cin >> n;
  vector<long> m(n);
  for (long i = 0; i < n; i++) cin >> m[i];
  cin >> t;
  long res = 0;
  sort(m.begin(), m.end());
  for (long i = 0; i < n; i++) {
    long k = 0;
    for (long j = i; j < n; j++) {
      if (m[j] - m[i] > t) break;
      k++;
    }
    res = max(res, k);
  }
  printf("%d", res);
}
