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