#include <bits/stdc++.h>
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int n, a[110], i, k, sum, t, max, j;
  while (scanf("%d", &n) != EOF) {
    sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    scanf("%d", &t);
    qsort(a, n, sizeof(a[0]), cmp);
    max = 0;
    for (i = 0; i < n; i++) {
      sum = 1;
      for (j = i + 1; j < n; j++) {
        if (a[j] - a[i] <= t)
          sum++;
        else
          break;
      }
      if (sum > max) max = sum;
    }
    printf("%d\n", max);
  }
  return 0;
}
