#include <bits/stdc++.h>
using namespace std;
void setup() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  setup();
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  int t;
  cin >> t;
  sort(arr.begin(), arr.end());
  int start = 0, next = -1, count = 1, mx = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] - arr[start] <= t) {
      count++;
      mx = max(mx, count);
    } else {
      int j = start + 1;
      while (arr[j] == arr[start]) {
        j++;
      }
      start = j;
      count = i - start + 1;
    }
  }
  cout << mx << endl;
  return 0;
}
