#include <bits/stdc++.h>
using namespace std;
map<long long, long long> counter;
std::vector<long long> arr;
long long fastexpo(long long x, long long y, long long m) {
  long long temp = 1;
  while (y > 0) {
    if (y & 1) temp = ((temp % m) * (x % m)) % m;
    x = ((x % m) * (x % m)) % m;
    y >>= 1;
  }
  return temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k, l, a;
  long long ans = 0, co = 1;
  cin >> n >> k >> l;
  std::vector<long long>::iterator it;
  long long aux = n * k, cur, pos;
  for (int i = 0; i < aux; ++i) {
    cin >> a;
    arr.push_back(a);
    counter[a]++;
  }
  sort(arr.begin(), arr.end());
  if (arr[n - 1] - arr[0] > l) {
    cout << "0";
    return 0;
  }
  it = upper_bound(arr.begin(), arr.end(), arr[0] + l);
  it--;
  pos = it - arr.begin();
  ans += arr[0];
  cur = 0;
  while (co < n) {
    if (pos - (cur + k) >= (n - co - 1)) {
      cur += k;
      ans += arr[cur];
      co++;
      continue;
    }
    while (pos - cur >= n - co) cur++;
    while (co < n) {
      ans += arr[cur];
      cur++;
      co++;
    }
  }
  cout << ans;
  return 0;
}
