#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m = 0, m1 = 0, l, q[1000], t;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  cin >> t;
  sort(q, q + n);
  for (int i = 0; i < n; i++) {
    l = 1;
    for (int j = i + 1; j < n; j++) {
      if (q[j] - q[i] <= t) l++;
    }
    if (l > m) m = l;
  }
  cout << m;
  return 0;
}
