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