#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ar[110], mx, k;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ar[i];
  cin >> k;
  sort(ar, ar + n);
  mx = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 1;
    for (int j = i + 1; j < n; j++) {
      if ((ar[j] - ar[i]) > k) break;
      cnt++;
    }
    mx = max(cnt, mx);
  }
  cout << mx << endl;
}
