#include <bits/stdc++.h>
int main() {
  int n, t, a[1002], ans, cnt = 0, i, j, k, max = 0, temp;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i < n; ++i)
    for (j = 0; j < (n - i); ++j)
      if (a[j] > a[j + 1]) {
        temp = a[j];
        a[j] = a[j + 1];
        a[j + 1] = temp;
      }
  scanf("%d", &t);
  for (i = 0; i < n; i++) {
    ans = 1;
    for (k = i + 1; k < n; k++) {
      if (a[k] - a[i] <= t)
        ans++;
      else
        break;
    }
    if (ans > max) max = ans;
  }
  printf("%d", max);
}
