#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  long long l;
  cin >> n >> k >> l;
  int m = n * k;
  vector<long long> a(m);
  vector<long long> good;
  for (int i = 0; i < n * k; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n * k; i++) {
    if (a[i] - a[0] <= l) good.push_back(a[i]);
  }
  if (good.size() < n) {
    cout << 0;
    return 0;
  }
  int need = n;
  n = good.size();
  long long ans = 0;
  for (int i = 0; i < n; i += k) {
    ans += good[i];
    need--;
  }
  for (int i = n - 1; i >= 0 && need > 0; i--) {
    if (i % k) {
      ans += good[i];
      need--;
    }
  }
  cout << ans;
}
