#include <bits/stdc++.h>
using namespace std;
vector<int> v;
long long solve(int n, int k, int l, vector<int>& v);
int main() {
  int n, k, l;
  cin >> n >> k >> l;
  for (int i = 0; i < n * k; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  cout << solve(n, k, l, v) << endl;
  return 0;
}
long long solve(int n, int k, int l, vector<int>& v) {
  int last_valid = 0;
  int m = n * k;
  for (int i = 0; i < n * k; i++) {
    if (v[i] - v[0] <= l)
      last_valid++;
    else
      break;
  }
  int num = last_valid * k;
  if (num < m) {
    return 0;
  }
  long long sum = 0;
  int left = m - last_valid;
  for (int i = last_valid - 1; left != 0; i--) {
    if (left >= (k - 1)) {
      sum = sum + v[i];
      left = left - (k - 1);
      last_valid--;
    } else {
      last_valid = last_valid - (k - 1) + left - 1;
      left = 0;
      sum = sum + v[last_valid];
    }
  }
  for (int i = 0; i < last_valid; i += k) {
    sum = sum + v[i];
  }
  return sum;
}
