#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
int n, m, t;
int a[N];
int main() {
  scanf("%d", &n);
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a[x]++;
  }
  scanf("%d", &t);
  int mx = -1;
  for (int i = 1; i <= 1000; i++) {
    int j = i;
    int sum = 0;
    int k = t + 1;
    while (k && j <= 1000) {
      sum += a[j];
      j++;
      k--;
    }
    if (sum > mx) {
      mx = sum;
    }
  }
  printf("%d\n", mx);
  return 0;
}
