#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[200] = {}, i, j, k, w, ans = 0;
  for (i = 0; i < n; i++) cin >> arr[i];
  cin >> w;
  sort(arr, arr + n);
  for (i = 0; i < n; i++) {
    int c = 1;
    for (j = i + 1; j < n; j++) {
      if (arr[j] - arr[i] <= w)
        c++;
      else
        break;
    }
    ans = (ans > c ? ans : c);
  }
  cout << ans << endl;
  return 0;
}
