#include <bits/stdc++.h>
using namespace std;
int a[110];
int main() {
  int n, j, k, now = 0, mx = 1;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> k;
  sort(a, a + n);
  for (int i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n && a[j] - a[i] <= k; j++)
      ;
    mx = max(mx, j - i);
  }
  cout << mx;
}
