#include <bits/stdc++.h>
using namespace std;
int N, T, t[155];
int Max = -1;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &t[i]);
  }
  scanf("%d", &T);
  sort(t, t + N);
  for (int i = 0; i < N; i++) {
    int a = (int)(upper_bound(t, t + N, t[i] + T) - t);
    Max = max(a - i, Max);
  }
  printf("%d", Max);
}
