#include <bits/stdc++.h>
using namespace std;
const long long N = 100005, INF = 2000000000000000000;
long long power(long long a, long long b, long long p) {
  if (a == 0) return 0;
  long long res = 1;
  a %= p;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    b >>= 1;
    a = (a * a) % p;
  }
  return res;
}
bool prime[N] = {true};
long long sum[N] = {0};
void pre() {
  memset(prime, true, sizeof(prime));
  for (long long i = 2; i <= N; i++) {
    if (prime[i]) {
      for (long long j = i * i; j <= N; j += i) {
        prime[j] = false;
      }
    }
  }
  for (long long i = 2; i < N; i++) {
    if (prime[i]) sum[i] += i;
    sum[i + 1] = sum[i];
  }
  return;
}
int32_t main() {
  long long n, j;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long t;
  cin >> t;
  sort(a, a + n);
  long long ans = -1;
  for (long long i = 0; i < n; i++) {
    for (j = i; j < n; j++) {
      if (a[j] - a[i] > t) {
        break;
      }
      ans = max(ans, j - i);
    }
    ans = max(ans, j - i);
  }
  cout << ans << endl;
  return 0;
}
