#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n + 1];
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int T;
  cin >> T;
  sort(a + 1, a + 1 + n);
  int result = INT_MIN;
  for (int i = 1; i <= n; ++i) {
    int target = a[i] + T;
    int l = i, r = n;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (a[mid] <= target) {
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    result = max(result, r - i + 1);
  }
  cout << result << "\n";
}
