#include <bits/stdc++.h>
using namespace std;
void solve(int testcase) {
  long long int n, k, L;
  cin >> n >> k >> L;
  long long int m = n * k;
  vector<long long int> a(m);
  for (int i = (0); i <= (m - 1); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int id = -1;
  long long int what = a[0] + L;
  for (int i = (0); i <= (m - 1); i++) {
    if (a[i] <= what) id++;
  }
  if (id + 1 < n) {
    cout << '0';
    return;
  }
  long long int sum = 0, done = n, rem = m - id - 1;
  int i = id;
  while (done && i >= 0) {
    if (rem >= k - 1 && i >= done - 1) {
      sum += a[i];
      i--;
      done--;
      rem -= (k - 1);
    } else {
      rem++;
      i--;
    }
  }
  cout << sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(10);
  clock_t b = clock();
  int t = 1;
  for (int tt = (1); tt <= (t); tt++) solve(tt);
  clock_t e = clock();
  cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
  return 0;
}
