#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long power(long long x, long long p, long long MOD) {
  if (p == 0) return 1 % MOD;
  if (p == 1) return x % MOD;
  long long res = power(x, p / 2, MOD);
  res = (long long)res * res % MOD;
  if (p & 1) res = (long long)res * x % MOD;
  return res;
}
int32_t main() {
  long long n, K, L;
  cin >> n >> K >> L;
  vector<long long> p;
  for (long long i = 0; i < n * K; i++) {
    long long x;
    cin >> x;
    p.push_back(x);
  }
  sort((p).begin(), (p).end());
  long long hi = upper_bound((p).begin(), (p).end(), p[0] + L) - p.begin();
  if (hi < n) {
    cout << 0 << endl;
    return 0;
  }
  vector<bool> used(hi);
  long long tot = 0;
  for (long long i = 0; i < hi; i += K) {
    used[i] = true;
    tot++;
  }
  long long ptr = hi - 1;
  while (tot < n) {
    assert(ptr >= 0);
    if (!used[ptr]) used[ptr] = true, tot++;
    ptr--;
  }
  long long ans = 0;
  for (long long i = 0; i < hi; i++) {
    if (used[i]) ans += p[i];
  }
  cout << ans << endl;
}
