#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, m, s, t, n, a[123456], b[123456], d, e, f, h;
vector<long long> p, q, r, rr;
int main() {
  cin >> n >> k >> l;
  t = n * k;
  for (i = 0; i < t; i++) {
    cin >> a[i];
  }
  sort(a, a + t);
  if (a[0] + l < a[n - 1]) {
    cout << 0;
    return 0;
  }
  m = n;
  while (m < t && a[0] + l >= a[m]) m++;
  m--;
  d = t - k;
  for (i = 0; i < n; i++) {
    e = min(m, d);
    d -= k;
    m--;
    s += a[e];
  }
  cout << s << endl;
  return 0;
}
