#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, li;
  cin >> n >> k >> li;
  long long A[n * k], ind = n * k;
  for (int i = 0; i < n * k; i++) {
    cin >> A[i];
  }
  sort(A, A + n * k);
  if (k == 1) {
    if (A[n * k - 1] - A[0] <= li) {
      long long sum = 0;
      for (int i = 0; i < n; i++) {
        sum = sum + A[i];
      }
      cout << sum << endl;
      return 0;
    } else {
      cout << "0" << endl;
      return 0;
    }
  }
  long long f = A[0] + li, l, r, flag = 0;
  for (int i = 0; i < n * k; i++) {
    if (A[i] > f) {
      ind = i;
      break;
    }
  }
  if (ind < n) {
    cout << "0" << endl;
    return 0;
  }
  if (ind == n * k) {
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      sum = sum + A[k * i];
    }
    cout << sum << endl;
    return 0;
  }
  long long B[n];
  B[0] = A[0];
  l = ind - 1, r = ind - 1;
  for (long long i = 0; i < n; i++) {
    if (r + k - 1 < n * k) {
      B[n - 1 - i] = A[l--];
      r = r + k - 1;
    } else {
      break;
    }
  }
  long long x = 0;
  for (int i = 0; i < l;) {
    B[x++] = A[i];
    i = i + k;
  }
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum = sum + B[i];
  }
  cout << sum << endl;
}
