#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int kase = 1;
  while (kase--) {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      v.push_back(a);
    }
    int t;
    cin >> t;
    sort(v.begin(), v.end());
    int curr_count = 0;
    int max_count = INT_MIN;
    int i = 0;
    int j = 0;
    while (j < n) {
      if ((v[j] - v[i]) <= t) {
        curr_count++;
        j++;
      } else {
        max_count = max(max_count, curr_count);
        i++;
        curr_count = j - i;
      }
    }
    max_count = max(max_count, curr_count);
    cout << max_count;
  }
  return 0;
}
