#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
int n, k, l, m;
int a[MAX_N];
int maxa = -1;
int SZ;
vector<long long> ans;
long long sum;
int main() {
  scanf("%d%d%d", &n, &k, &l);
  m = n * k;
  for (int i = 0; i < m; i++) scanf("%d", &a[i]);
  sort(a, a + m);
  for (int i = 0; i < m && a[i] - a[0] <= l; i++) maxa = max(maxa, i);
  SZ = maxa + 1;
  if (SZ < n) {
    printf("%d\n", 0);
    return 0;
  }
  for (int i = 0, cnt = 0; i <= maxa; i++, cnt++) {
    if (cnt == k) cnt = 0;
    if (SZ == n) {
      for (; i <= maxa; i++) ans.push_back(a[i]);
      continue;
    }
    if (cnt == 0)
      ans.push_back(a[i]);
    else
      SZ--;
  }
  for (auto i : ans) sum += i;
  printf("%lld\n", sum);
  return 0;
}
