#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ara[n];
  for (int i = 0; i < n; i++) cin >> ara[i];
  sort(ara, ara + 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 (abs(ara[i] - ara[j]) <= t) c++;
    }
    ans = max(ans, c);
  }
  cout << ans << endl;
  return 0;
}
