#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  int n, m, i, j, k, s, t, l;
  long long ans;
  scanf("%d%d%d", &n, &k, &l);
  for (i = 1; i <= n * k; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n * k + 1);
  s = 1;
  while (a[s] <= a[1] + l && s <= n * k) s++;
  ans = 0;
  if (s > n * k) {
    for (i = 1; i <= n * k; i += k) ans += (long long)a[i];
    printf("%I64d\n", ans);
    return 0;
  } else {
    t = n;
    for (i = 1; i < s; i += k) {
      ans += (long long)a[i];
      t--;
    }
    i = s - 1;
    while (t > 0) {
      if ((i - 1) % k == 0) i--;
      if (i == 0) break;
      ans += (long long)a[i];
      i--;
      t--;
      if (i == 0) break;
    }
    if (t != 0)
      printf("0\n");
    else
      printf("%I64d\n", ans);
  }
  return 0;
}
