#include <bits/stdc++.h>
using namespace std;
int n, s[1005], t, res;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d", &s[i]);
  scanf("%d", &t);
  sort(s + 1, s + n + 1);
  int p = 0;
  for (int i = (1); i <= (n); i++) {
    while (p < n && s[p + 1] - s[i] <= t) p++;
    res = max(res, p - i + 1);
  }
  printf("%d\n", res);
  return 0;
}
