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