#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int student;
  int time[1005];
  memset(time, 0, sizeof(time));
  for (int i = 0; i < n; i++) {
    scanf("%d", &student);
    time[student]++;
  }
  int T;
  scanf("%d", &T);
  int maxima = -1;
  int add;
  for (int i = 0; i + T < 1005; i++) {
    add = 0;
    for (int j = i; j <= i + T; j++) {
      add += time[j];
      maxima = max(maxima, add);
    }
  }
  printf("%d\n", maxima);
  return 0;
}
