#include <bits/stdc++.h>
using namespace std;
vector<int> t;
int n, x, i, j, h, sol, temp;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    t.push_back(x);
  }
  cin >> h;
  sort(t.begin(), t.end());
  sol = 0;
  for (i = 0; i < n; i++) {
    temp = 1;
    for (j = i + 1; j < n; j++) {
      if (t[j] - t[i] <= h) temp++;
    }
    sol = max(sol, temp);
  }
  cout << sol << endl;
  return 0;
}
