#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int t[n];
  for (int i = 0; i < n; i++) cin >> t[i];
  sort(t, t + n);
  int T;
  cin >> T;
  vector<pair<int, int> > v;
  v.push_back(pair<int, int>(0, t[0]));
  for (int i = 1; i < n; i++)
    if (t[i] != v.back().second) v.push_back(pair<int, int>(0, t[i]));
  for (int i = 0; i < v.size(); i++)
    for (int j = 0; j < n; j++)
      if (t[j] >= v[i].second && t[j] - v[i].second <= T) v[i].first++;
  sort(v.begin(), v.end());
  cout << v.back().first << endl;
  return 0;
}
