#include <bits/stdc++.h>
using namespace std;
int a[3000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int t;
  cin >> t;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    for (int j = a[i]; j <= a[i] + t; j++) {
      for (int k = 0; k < n; k++) {
        if (a[k] == j) tmp++;
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
