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