#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n, k, l;
  cin >> n >> k >> l;
  long long arr[n * k];
  for (int i = 0; i < n * k; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n * k);
  auto pos = upper_bound(arr, arr + n * k, arr[0] + l);
  pos--;
  int po = pos - arr;
  if (po + 1 < n) {
    cout << 0 << "\n";
    return 0;
  }
  long long ans = 0;
  int count = 0;
  vector<long long> v;
  for (int i = 0; i <= po && count < n; i++) {
    if (i % (k) == 0) {
      count++;
      ans += arr[i];
    } else {
      v.push_back(arr[i]);
    }
  }
  int i = v.size() - 1;
  while (count < n) {
    ans += v[i];
    i--;
    count++;
  }
  cout << ans << "\n";
}
