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