#include <bits/stdc++.h>
using namespace std;
int n, k, l, a[100050];
int main() {
  scanf("%d%d%d", &n, &k, &l);
  for (register int i = 1; i <= n * k; ++i) scanf("%d", &a[i]);
  sort(a + 1, a + n * k + 1);
  int xx = a[1], yy = a[1] + l;
  int pos = n * k;
  while (pos && a[pos] > yy) --pos;
  if (pos < n) return printf("0"), 0;
  int x = 1;
  long long ans = 0;
  for (register int i = 1; i <= n; ++i) {
    ans += a[x++];
    for (register int j = 1; j <= k - 1; ++j)
      if (pos - x + 1 > n - i) x++;
  }
  printf("%I64d", ans);
  return 0;
}
