#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, t[N], T;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  sort(t + 1, t + n + 1);
  scanf("%d", &T);
  int ans = 0;
  for (int i = 1, j = 0; i <= n; i++) {
    for (; j < n && t[j + 1] <= t[i] + T; j++)
      ;
    ans = max(ans, j - i + 1);
  }
  printf("%d\n", ans);
}
