#include <bits/stdc++.h>
using namespace std;
const int MAXn = 100 + 13;
int n, k, t[MAXn];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> t[i];
  cin >> k;
  sort(t, t + n);
  int i = 0, j = 0, d = 0, num = 0, ans = 0;
  while (j < n) {
    d = t[j++] - t[i];
    while (d > k) d -= t[i++];
    num = j - i;
    ans = max(ans, num);
  }
  cout << ans << endl;
  return 0;
}
