#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 55;
const int inf = 1e9 + 77;
const int MOD = 1e9 + 7;
const double eps = 0.0000001;
unsigned long long a[2 * MAX];
int main() {
  long long n, k, l;
  cin >> n >> k >> l;
  for (int i = 0; i < n * k; ++i) cin >> a[i];
  sort(a, a + n * k);
  if (a[n - 1] - a[0] > l) {
    cout << 0;
    return 0;
  }
  unsigned long long sum = 0;
  int pos = -1;
  for (int i = n * k - 1; i > 0; --i) {
    if (a[i] - a[0] > l) {
      pos = i;
    } else
      break;
  }
  if (-1 == pos) pos = n * k;
  long long m = 0;
  for (int i = 0; i < pos;) {
    sum += a[i];
    ++m;
    i += min(pos - i - n + m, k);
  }
  cout << sum;
  return 0;
}
