#include <bits/stdc++.h>
using namespace std;
int N, T, n[100];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%d", &n[i]);
  scanf("%d", &T);
  sort(n, n + N);
  int stm = 0, best = 0, sum = 0;
  for (int i = 0; i < N; ++i) {
    ++sum;
    while (n[i] - n[stm] > T) {
      --sum;
      ++stm;
    }
    if (sum > best) best = sum;
  }
  printf("%d\n", best);
  return 0;
}
