#include <bits/stdc++.h>
using namespace std;
int n, t[123], T, r;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> t[i];
  cin >> T;
  for (int i = 0; i < n; ++i) {
    int k = 0;
    for (int j = 0; j < n; ++j) {
      if (t[i] <= t[j] && t[j] <= t[i] + T) ++k;
    }
    r = max(k, r);
  }
  cout << r;
}
