#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int val[n];
  for (int i = 0; i < n; i++) {
    cin >> val[i];
  }
  sort(val, val + n);
  int t;
  cin >> t;
  int res = 0;
  for (int i = 1; i <= 1000; i++) {
    int curr = 0;
    for (int j = 0; j < n; j++) {
      if (i <= val[j] and val[j] <= i + t) {
        curr++;
      }
    }
    res = max(res, curr);
  }
  cout << res;
}
