#include <bits/stdc++.h>
using namespace std;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
long long ara[100010];
bool mark[100010];
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, k;
  long long l;
  cin >> n >> k >> l;
  int lim = n * k;
  for (int i = 1; i <= lim; i++) {
    cin >> ara[i];
  }
  sort(ara + 1, ara + lim + 1);
  for (int i = 1; i <= lim; i += k) {
    mark[i] = 1;
  }
  long long yo = ara[1] + l;
  int baki = 0;
  int pp;
  for (int i = lim; i >= 1; i--) {
    if (ara[i] <= yo) {
      pp = i;
      break;
    }
    if (mark[i]) {
      baki++;
      mark[i] = 0;
    }
  }
  for (int i = pp; i >= 1; i--) {
    if (baki == 0) {
      break;
    }
    if (mark[i] == 0) {
      baki--;
      mark[i] = 1;
    }
  }
  if (baki) {
    cout << 0;
    return 0;
  }
  long long sum = 0;
  for (int i = 1; i <= lim; i++) {
    if (mark[i]) {
      sum += ara[i];
    }
  }
  cout << sum;
  return 0;
}
