#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int dcmp(double x) {
  if (fabs(x) <= 1e-9) return 0;
  return x < 0 ? -1 : 1;
}
struct Point {
  double x, y;
  double ang;
  Point() {}
  Point(double x, double y) : x(x), y(y) {}
  Point operator-(const Point &a) const { return Point(x - a.x, y - a.y); }
  Point operator+(const Point &a) const { return Point(x + a.x, y + a.y); }
  Point operator*(const double &a) const { return Point(x * a, y * a); }
  bool operator<(const Point &a) const {
    if (dcmp(ang) == 0) return (x * x + y * y) <= a.x * a.x + a.y * a.y;
    return ang < a.ang;
  }
  bool operator==(const Point &a) const { return x == a.x && y == a.y; }
};
struct cycle {
  Point p;
  long long r;
  cycle() {}
  cycle(Point p, long long r) : p(p), r(r) {}
};
Point Rotate(Point v, double ang) {
  return Point(v.x * cos(ang) - v.y * sin(ang),
               v.x * sin(ang) + v.y * cos(ang));
}
double Dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double dis(Point a) { return sqrt(Dot(a, a)); }
double Cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
int pt[200005], n, T;
int ti[200005];
void solve() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  memset(ti, 0, sizeof(ti));
  for (int i = 1; i <= n; i++) cin >> T, ti[T]++;
  cin >> T;
  int ans = 0;
  for (int i = 0; i <= 1000; i++) {
    int cnt = 0;
    for (int j = i; j <= i + T; j++) {
      cnt += ti[j];
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) solve();
  return 0;
}
