#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
  int n, k, l;
  scanf("%d%d%d", &n, &k, &l);
  int m = n * k;
  for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + m);
  int all;
  for (all = 2; all <= m; all++) {
    if (a[all] - a[1] > l) break;
  }
  all--;
  if (all < n) {
    printf("0\n");
    return 0;
  }
  long long ans = 0;
  int r = all;
  int need = n;
  for (int i = 1; i <= all;) {
    ans += a[i];
    need--;
    r--;
    if (r > need) {
      int temp = min(k - 1, r - need);
      r -= temp;
      i += temp;
      i++;
    } else
      i++;
  }
  printf("%I64d\n", ans);
  return 0;
}
