#include <bits/stdc++.h>
using namespace std;
int vis[100001];
int main() {
  int t, n, a[1001], i, j, k, cnt = 0, ans = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    vis[a[i]]++;
  }
  sort(a, a + n);
  cin >> t;
  for (i = 0; i < n; i++) {
    cnt = 0;
    for (j = 0; j <= t; j++) {
      cnt += vis[a[i] + j];
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
