#include <bits/stdc++.h>
using namespace std;
int a[200000];
int main() {
  int n, k, l;
  cin >> n >> k >> l;
  for (int i = 0; i < n * k; ++i) {
    cin >> a[i];
  }
  sort(a, a + n * k);
  int id = 0;
  long long int sum = a[id];
  int last = upper_bound(a + 1, a + (n - 1) * k + 1, a[0] + l) - a - 1;
  if (last <= n - 2) {
    cout << "0\n";
    return 0;
  }
  sum = a[last];
  id = last;
  for (int i = n - 2; i >= 0; --i) {
    int b = i * k;
    id = id - 1;
    if (id > b) {
      id = b;
    }
    sum += a[id];
  }
  cout << sum << "\n";
  return 0;
}
