#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000;
int a[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int T;
  cin >> T;
  int maxx = -10;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++)
      if (a[j] - a[i] <= T && a[j] >= a[i]) ans++;
    if (ans > maxx) maxx = ans;
  }
  cout << maxx;
}
