#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int T;
  cin >> T;
  sort(a, a + n);
  int ans = -1;
  for (int i = 0; i < n; i++) {
    int j = i;
    for (; j < n; ++j)
      if (a[j] - a[i] > T) break;
    ans = max(ans, j - i);
  }
  cout << ans << endl;
  return 0;
}
