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