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