#include <bits/stdc++.h>
int comp(const void *a, const void *b) {
  return *(int *)a > *(int *)b ? 1 : -1;
}
int main() {
  int n, t, a[101], i, j;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) scanf("%d", a + i);
    scanf("%d", &t);
    qsort(a, n, sizeof(a[0]), comp);
    int x = 0, y;
    for (i = 0; i < n; i++) {
      for (j = i, y = 0; a[j] <= a[i] + t && j < n; y++, j++)
        ;
      x = x > y ? x : y;
    }
    printf("%d\n", x);
  }
  return 0;
}
