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