#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-10;
inline int cmp(double x, double y = 0, double tol = EPS) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  long long l;
  cin >> n >> k >> l;
  int m = n * k;
  vector<long long> a(m);
  for (int i = 0; i < m; i++) cin >> a[i];
  sort((a).begin(), (a).end());
  int v = upper_bound((a).begin(), (a).end(), a[0] + l) - a.begin();
  if (v < n) {
    cout << "0" << endl;
    return 0;
  }
  long long ret = 0;
  int u = v - 1;
  for (int i = 0; i < n; i++) {
    int c = k - 1;
    if (v < m) {
      int b = min(c, m - v);
      v += b;
      c -= b;
    }
    u -= c;
    ret += a[u--];
  }
  cout << ret << endl;
  return 0;
}
