#include <bits/stdc++.h>
using namespace std;
int dir1[8][2] = {1, 2, 2, 1, 2, -1, 1, -2, -1, 2, -2, 1, -1, -2, -2, -1};
int dir2[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
int dir3[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
bool Isleap(int year) {
  if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return true;
  return false;
}
bool isPrime(int x) {
  if (x == 1)
    return false;
  else if (x == 2)
    return true;
  for (int i = 2; i <= sqrt(x * 1.0); ++i) {
    if (x % i == 0) return false;
  }
  return true;
}
int sqr(int x) { return x * x; }
int main() {
  int a[120];
  int n, t;
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    sort(a, a + n);
    scanf("%d", &t);
    int maxn = -1, ans = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = n - 1; j > i; --j) {
        if (a[j] - a[i] <= t) {
          ans = j - i + 1;
          break;
        } else
          ans = 1;
      }
      maxn = max(maxn, ans);
    }
    printf("%d\n", maxn);
  }
  return 0;
}
