#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main() {
  int n = 0, t = 0, T = 0, r = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    r = max(r, t);
    a[t]++;
  }
  scanf("%d", &T);
  for (int i = 1; i <= r; i++) a[i] += a[i - 1];
  int MAX = (T >= r) ? a[r] : 0;
  for (int i = 0; i < r - T; i++) MAX = max(MAX, a[i + T + 1] - a[i]);
  printf("%d\n", MAX);
  return 0;
}
