#include <bits/stdc++.h>
using namespace std;
int n, a[1000];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  sort(a + 1, a + 1 + n);
  int T;
  scanf("%d", &T);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int cur = 0;
    for (int j = i; j <= n; ++j) {
      if (a[i] + T >= a[j]) cur++;
    }
    ans = max(ans, cur);
  }
  printf("%d\n", ans);
  return 0;
}
