#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int v[100100], flag[100100];
int main() {
  int n, k, l;
  scanf("%d %d %d", &n, &k, &l);
  for (int i = 0; i < n * k; i++) scanf("%d", &v[i]);
  sort(v, v + n * k);
  ll limite = v[0] + l;
  int left = upper_bound(v, v + n * k, limite) - v;
  --left;
  if (left + 1 < n) {
    cout << 0 << endl;
    return 0;
  }
  ll sum = 0;
  int cnt = 0;
  for (int i = 0; i <= left; i += k) {
    if (cnt == n) break;
    flag[i] = true;
    sum += v[i];
    cnt++;
  }
  for (int i = left; i >= 0; i--) {
    if (cnt == n) break;
    if (!flag[i]) {
      sum += v[i];
      cnt++;
    }
  }
  printf("%lld\n", sum);
  return 0;
}
