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