#include <bits/stdc++.h>
using namespace std;
int ar[10000], vis[10000];
int main() {
  int i, j, k, l, t, r, s, m, md, n, a, b, c, d, e, f, g, h, u, v;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
  }
  sort(ar, ar + n);
  scanf("%d", &t);
  a = 0;
  m = 0;
  for (i = 0; i < n; i++) {
    l = i;
    h = n - 1;
    md = (h + l) / 2;
    b = ar[i] + t;
    while (l <= h) {
      if (ar[md] <= b) {
        if (md + 1 < n && ar[md + 1] <= b)
          l = md + 1;
        else
          break;
      } else
        h = md - 1;
      md = (l + h) / 2;
    }
    if (md - i + 1 > m) m = md - i + 1;
  }
  printf("%d\n", m);
  return 0;
}
