#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
int n, a[111], m, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &m);
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    int j = i;
    while (j <= n) {
      if (a[j] - a[i] > m) break;
      j++;
    }
    j--;
    ans = max(ans, j - i + 1);
  }
  printf("%d\n", ans);
}
