#include <bits/stdc++.h>
int main() {
  int n, i, j, s[100], t, y = 0, y1, y2, y3, x, z;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  scanf("%d", &z);
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j <= n - 2 - i; j++) {
      if (s[j] > s[j + 1]) {
        t = s[j];
        s[j] = s[j + 1];
        s[j + 1] = t;
      }
    }
  }
  for (i = 0; i < n; i++) {
    x = s[i];
    y1 = 0;
    y2 = 0;
    y3 = 0;
    for (j = 0; j < n; j++) {
      if (s[j] <= x + z && s[j] >= x) y1 = y1 + 1;
      if (s[j] >= x - z && s[j] <= x) y2 = y2 + 1;
    }
    if (y1 > y2)
      y3 = y1;
    else
      y3 = y2;
    if (y < y3) y = y3;
  }
  printf("%d", y);
  return 0;
}
