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