#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, T, a[111], sum = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cin >> T;
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++)
      if (a[j] - a[i] <= T) sum = max(sum, j - i + 1);
  }
  cout << sum;
  return 0;
}
