#include <bits/stdc++.h>
using namespace std;
int a[100010], mi[100010], viz[100010], c[100010];
int gmin(int a, int b) { return a < b ? a : b; }
int main() {
  int n, k, l, ma;
  scanf("%d%d%d", &n, &k, &l);
  for (int i = 1; i <= n * k; i++) scanf("%d", &a[i]);
  sort(&a[1], &a[n * k + 1]);
  ma = a[1] + l;
  int pm;
  for (pm = 1; pm <= n * k; pm++) {
    if (a[pm] > ma) break;
  }
  pm--;
  if (pm < n) {
    puts("0");
    return 0;
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) mi[i] = 2147483647;
  int now = n;
  pm++;
  for (int i = 1; i < pm; i++) {
    mi[now] = gmin(mi[now], a[i]);
    c[now]++;
    if (c[now] == k || pm - i <= now) now--;
  }
  for (int i = 1; i <= n; i++) res += mi[i];
  printf("%I64d", res);
  return 0;
}
