#include <bits/stdc++.h>
using namespace std;
unsigned long long n, k, l, a[100003], sum = 0;
int main() {
  cin >> n >> k >> l;
  for (unsigned long long i = 0; i < n * k; i++) cin >> a[i];
  sort(a, a + n * k);
  unsigned long long yu = upper_bound(a, a + n * k, a[0] + l) - a;
  if (yu < n) {
    cout << '0' << endl;
    return 0;
  }
  yu -= n;
  unsigned long long id = 0;
  for (unsigned long long ii = 0; ii < n; ii++) {
    sum += a[id];
    if (yu >= k) {
      id += k;
      yu = yu - k + 1;
    } else {
      id += yu + 1;
      yu = 0;
    }
  }
  cout << sum << endl;
  return 0;
}
