#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int t;
  cin >> t;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int c = 1;
    for (int j = i + 1; j < n; j++) {
      if (a[j] - a[i] <= t)
        c++;
      else
        break;
    }
    ans = max(ans, c);
  }
  cout << ans << "\n";
  return 0;
}
