#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> k;
    arr[i] = k;
  }
  int c;
  cin >> c;
  sort(arr, arr + n);
  int ans = -1;
  for (int i = 0; i < n; i++) {
    int last = i;
    for (int j = i; j < n; j++) {
      if (arr[j] - arr[i] > c) {
        break;
      }
      last = j;
    }
    ans = max(ans, last - i);
  }
  cout << ans + 1;
  return 0;
}
