#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:267386880")
using namespace std;
void solve() {
  int n;
  scanf("%d", &n);
  vector<int> data(n);
  for (int i(0); i <= ((long long)(n)-1); ++i) scanf("%d", &data[i]);
  int t;
  scanf("%d", &t);
  sort((data).begin(), (data).end());
  int res(0);
  for (int i(0); i <= ((long long)(n)-1); ++i)
    for (int j(i); j <= (n - 1); ++j)
      if (data[j] - data[i] <= t) res = max(res, j - i + 1);
  printf("%d\n", res);
}
void bruteforce() {}
int main() {
  solve();
  bruteforce();
  return 0;
}
