#include <bits/stdc++.h>
using namespace std;
const int oo = 110;
int n, m, a[oo], b[oo], ma;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++)
      if (a[j] - a[i] <= m) b[i]++;
  for (int i = 0; i < n; i++) ma = max(b[i], ma);
  cout << ma;
  return 0;
}
