#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, t[101], T, cnt[1004] = {0}, max = 0, sum;
  cin >> n;
  for (i = 0; i < n; i++) cin >> t[i], cnt[t[i] - 1]++;
  cin >> T;
  for (i = 0; i < 1003 - T; i++) {
    sum = 0;
    for (j = i; j <= i + T; j++) sum += cnt[j];
    max = max > sum ? max : sum;
  }
  cout << max << endl;
  return 0;
}
