#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100000], t, ans = 1, l = 0, r = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> t;
  sort(a, a + n);
  while (l < n) {
    while (r < n && a[r] - a[l] <= t) r++;
    if (r - l > ans) ans = r - l;
    l++;
  }
  cout << ans;
  return 0;
}
