#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k, l;
  cin >> n >> k >> l;
  vector<long long> v;
  for (long long i = 0; i < n * k; i++) {
    long long a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  bool bol = true;
  long long tot = 0;
  long long maxi = n * k - 1;
  for (long long i = 0; i < n * k; i++) {
    if (v[i] - v[0] > l) {
      maxi = i - 1;
      break;
    }
  }
  long long a = n;
  for (long long i = 0; i < n * k && i <= maxi; i += k) {
    tot += v[i];
    a--;
  }
  for (long long i = maxi; i >= 0 && a > 0; i--) {
    if (i % k != 0) {
      tot += v[i];
      a--;
    }
  }
  if (a == 0)
    cout << tot;
  else
    cout << 0;
  return 0;
}
