#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, l, sum = 0, N;
  cin >> n >> k >> l;
  N = n * k;
  int a[N + 2];
  for (int i = 1; i <= N; i++) cin >> a[i];
  sort(a + 1, a + N + 1);
  int allowed = a[1] + l, allowed_ind = N;
  for (int i = 1; i <= N; i++) {
    if (a[i] > allowed) {
      allowed_ind = i - 1;
      break;
    }
  }
  if (allowed_ind < n) {
    cout << 0;
    return 0;
  }
  int need = 0;
  for (int i = 1; i <= allowed_ind; i += k) {
    sum += a[i];
    need++;
  }
  int r = n - need;
  for (int i = 0; i < r;) {
    if (allowed_ind % k != 1) {
      i++;
      sum += a[allowed_ind];
    }
    allowed_ind--;
  }
  cout << sum;
  return 0;
}
