#include <bits/stdc++.h>
void pai_xu(int a[], int n) {
  int m, i, j;
  for (i = 0; i < n; i++)
    for (j = i + 1; j < n; j++)
      if (a[j] < a[i]) {
        m = a[i];
        a[i] = a[j];
        a[j] = m;
      }
}
int main() {
  int i, j, n, t0, a[100], s = 1, p = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  scanf("%d", &t0);
  pai_xu(a, n);
  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[j] - a[i] <= t0) {
        s = j - i + 1;
        break;
      } else
        s = 1;
    }
    if (s > p) p = s;
  }
  putchar('\n');
  printf("%d", p);
  return 0;
}
