#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, T;
  vector<int> v;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    v.push_back(x);
  }
  scanf("%d", &T);
  sort(v.begin(), v.end());
  int count = 0;
  int max = 0;
  for (int i = 0; i < v.size(); i++) {
    count = 0;
    for (int j = i; j < v.size(); j++) {
      if (abs(v[i] - v[j]) <= T) count++;
    }
    if (max < count) max = count;
  }
  printf("%d", max);
  return 0;
}
