#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> v;
  for (long long i = 0; i < n; i += 1) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  long long t;
  cin >> t;
  sort(v.begin(), v.end());
  if ((long long)v.size() == 1)
    cout << 1 << "\n";
  else {
    long long ans = LLONG_MIN;
    for (long long i = 0; i < (long long)v.size(); i += 1) {
      for (long long j = i + 1; j < (long long)v.size(); j += 1) {
        if (v[j] - v[i] <= t)
          ans = max(ans, j - i + 1);
        else {
          ans = max(ans, 1ll);
          break;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
