#include <bits/stdc++.h>
using namespace std;
long long a[200000];
long long n, k, l;
long long mins[200000];
long long cnt[200000];
stack<long long> fuck;
stack<long long> suck;
int main() {
  memset(mins, 31, sizeof(mins));
  cin >> n >> k >> l;
  for (long long i = 0; i < n * k; i++) {
    cin >> a[i];
  }
  sort(a, a + (n * k));
  long long go = a[0] + l;
  for (long long i = 0; i < n * k; i++) {
    if (go >= a[i]) {
      fuck.push(a[i]);
    } else {
      break;
    }
  }
  if (fuck.size() < n) {
    puts("0");
    return 0;
  }
  while (fuck.empty() == false) {
    suck.push(fuck.top());
    fuck.pop();
  }
  int buck = 0;
  while (suck.empty() == false) {
    int rem = (n - 1 - buck);
    if (rem < suck.size()) {
      mins[buck] = min(mins[buck], suck.top());
      cnt[buck]++;
      if (cnt[buck] == k) buck++;
      suck.pop();
    } else {
      buck++;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += mins[i];
  cout << ans << endl;
  return 0;
}
