#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  int t;
  cin >> t;
  sort(a, a + n);
  int cnt = 0;
  if (n == 1)
    printf("1\n");
  else {
    for (int i = 0; i < n - 1; i++) {
      int tmp = t;
      int b = 1;
      for (int j = i + 1; j < n; j++) {
        if (a[j] - a[i] <= tmp) {
          b++;
        } else
          break;
      }
      if (b > cnt) cnt = b;
    }
    cout << cnt << endl;
  }
  return 0;
}
