#include <bits/stdc++.h>
using namespace std;
long long n, k, l;
vector<long long> a;
vector<long long> v, b;
int main() {
  long long i, j;
  scanf("%lld", &n);
  scanf("%lld", &k);
  scanf("%lld", &l);
  for (i = 1; i <= n * k; i++) {
    scanf("%lld", &j);
    a.push_back(j);
  }
  sort(a.begin(), a.end());
  j = k;
  for (i = 1; i < a.size(); i++) {
    if (i == j) {
      b.push_back(a[i]);
      j += k;
    } else {
      if (a[i] - a[0] <= l) v.push_back(a[i]);
    }
  }
  long long ans = a[0];
  for (i = (int)b.size() - 1; i >= 0; i--) {
    if (b[i] - a[0] > l) {
      if (v.size() == 0) return cout << 0 << endl, 0;
      ans += (v[v.size() - 1]);
      v.pop_back();
    } else
      ans += b[i];
  }
  cout << ans << endl;
  return 0;
}
