#include <bits/stdc++.h>
using namespace std;
const int maxN = 100000, intMax = 2147483647, maxK = 100000, maxM = 100000;
int min(int a, int b) {
  if (a < b) return a;
  return b;
}
long long n, k, l, a[maxM];
int main() {
  scanf("%lld %lld %lld", &n, &k, &l);
  for (long long i = 0; i < n * k; i++) scanf("%lld", &a[i]);
  sort(begin(a), begin(a) + n * k);
  if (a[n - 1] - a[0] > l) {
    printf("0");
    return 0;
  }
  long long i = 0;
  for (; i < n * k && a[i] - a[0] <= l; i++)
    ;
  long long s = 0;
  long long ind = 0;
  long long q = 0;
  while (i - ind - k >= n - q - 1 && q < n - 1) {
    s += a[ind];
    ind += k;
    q++;
  }
  s += a[ind];
  q++;
  ind = i - 1;
  for (; q < n; q++, ind--) s += a[ind];
  printf("%lld", s);
  return 0;
}
