#include <bits/stdc++.h>
using namespace std;
long long int n, a[105], t, ans = -1;
int main() {
  scanf("%lld", &n);
  for (long long int i = 0; i < n; ++i) scanf("%lld", &a[i]);
  scanf("%lld", &t);
  sort(a, a + n);
  for (long long int i = 0; i < n; ++i) {
    long long int j = i;
    while (a[i] + t >= a[j] && j < n) j++;
    ans = max(ans, j - i);
  }
  printf("%lld", ans);
}
