#include <bits/stdc++.h>
using namespace std;
int a[105];
int main() {
  int n;
  cin >> n;
  for (int i = (1); (i) <= (n); i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int t;
  cin >> t;
  int st = 1, en = 1, cnt = 0, mx = 0;
  while (en != n + 1) {
    if (a[en] - a[st] <= t) {
      cnt++;
      if (a[en + 1] - a[st] > t) mx = max(mx, cnt);
      if (a[en + 1] - a[st] <= t and en == n) mx = max(mx, cnt);
      en++;
    } else {
      cnt--;
      st++;
    }
  }
  cout << mx;
}
