#include <bits/stdc++.h>
using namespace std;
int a[1005];
int cnt[1005];
int main() {
  memset(a, 0, sizeof(a));
  memset(cnt, 0, sizeof(cnt));
  int n, t, j = 0, k, flag = 0;
  scanf("%d", &n);
  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++) {
    if (flag) break;
    for (k = i + 1; k <= n; k++) {
      if (a[k] - a[i] <= t) {
        cnt[j]++;
        if (k == n) flag = 1;
      } else {
        j++;
        break;
      }
    }
  }
  sort(cnt, cnt + j + 1);
  printf("%d\n", cnt[j] + 1);
}
