#include <bits/stdc++.h>
using namespace std;
int p[111], n, T;
bool judge(int x) {
  if (x == 0) return true;
  for (int i = n - 1; i >= x - 1; i--)
    if (p[i] - p[i - x + 1] <= T) return true;
  return false;
}
int main() {
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) scanf("%d", &p[i]);
    sort(p, p + n);
    cin >> T;
    int l = 0, r = n, m;
    while (l < r) {
      m = (l + r + 1) / 2;
      if (judge(m))
        l = m;
      else
        r = m - 1;
    }
    cout << l << endl;
  }
  return 0;
}
