#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i = 0; i < n; i++) cin >> t[i];
  int T;
  cin >> T;
  sort(t.begin(), t.end());
  int max1 = 0;
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (int j = i; j < n; j++)
      if (t[j] - t[i] <= T)
        count++;
      else
        break;
    max1 = max(max1, count);
  }
  cout << max1 << endl;
  return 0;
}
