#include <bits/stdc++.h>
using namespace std;
int n, a[111], t;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  sort(a, a + n);
  scanf("%d", &t);
  int c, mx = -1;
  for (int i = 0; i < n; ++i) {
    c = 1;
    for (int j = i + 1; j < n; ++j)
      if (abs(a[i] - a[j]) <= t) ++c;
    mx = max(mx, c);
  }
  printf("%d", mx);
  return 0;
}
