#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int l, h, m, n, T, t[123], i, ans, j, tmp;
  cin >> n;
  for (i = 0; i < n; i++) cin >> t[i];
  cin >> T;
  ans = INT_MIN;
  sort(t, t + n);
  for (i = 0; i < n; i++) {
    l = i, h = n - 1, tmp = 0;
    while (l <= h) {
      m = (l + h) / 2;
      if (t[i] + T >= t[m])
        l = m + 1, tmp = max(tmp, m - i + 1);
      else
        h = m - 1;
    }
    ans = max(ans, tmp);
  }
  if (ans == INT_MIN) ans = 0;
  cout << ans << endl;
  return 0;
}
