#include <bits/stdc++.h>
using namespace std;
const int N = 1E5 + 10;
int num[N];
int n, k, m, xx;
int main() {
  scanf("%d%d%d", &n, &k, &xx);
  m = n * k;
  for (int i = 0; i < m; i++) scanf("%d", &num[i]);
  sort(num, num + m);
  int up = num[0] + xx;
  int l = 0, r = m - 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (num[mid] > up)
      r = mid - 1;
    else
      l = mid + 1;
  }
  while (num[l] > up) l--;
  if (l + 1 < n) {
    puts("0");
    return 0;
  }
  int left = l + 1 - n;
  int cnt;
  if (k == 1)
    cnt = 0;
  else
    cnt = left / (k - 1) + 1;
  long long tot = 0;
  int op = 0;
  for (int i = 0; i < cnt; i++) {
    tot += (long long)num[op];
    op += k;
  }
  cnt = n - cnt;
  op = l;
  for (int i = 0; i < cnt; i++) {
    tot += (long long)num[op];
    op--;
  }
  printf("%lld", tot);
}
