#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  int cnt = 0, t;
  cin >> t;
  sort(arr, arr + n);
  for (int i = 0; i < n; ++i) {
    int temp = 1;
    for (int j = i + 1; j < n && arr[j] - arr[i] <= t; ++j) {
      ++temp;
    }
    cnt = max(cnt, temp);
  }
  cout << cnt << '\n';
  return 0;
}
