#include <bits/stdc++.h>
using namespace std;
long long int a[100005];
long long int b[100005];
int cmp(long long int a, long long int b) { return a < b; }
int main() {
  long long int i, j, m, n, k, l, min, sum, num;
  scanf("%lld%lld%lld", &n, &k, &l);
  m = n * k;
  sum = 0;
  min = 10000000000;
  for (i = 1; i <= m; i++) {
    scanf("%lld", &a[i]);
    if (min > a[i]) min = a[i];
  }
  j = 0;
  for (i = 1; i <= m; i++) {
    if (a[i] <= min + l) {
      j++;
      b[j] = a[i];
    }
  }
  num = j;
  if (num < n) {
    printf("0");
    return 0;
  }
  sort(b + 1, b + num + 1, cmp);
  i = 1;
  j = 0;
  while (i <= num) {
    if (num - i + 1 - (n - j) >= k) {
      sum = sum + b[i];
      j++;
      i = i + k;
    } else if (num - i + 1 > n - j) {
      sum = sum + b[i];
      j++;
      i = i + num - i + 1 - (n - j);
    } else {
      sum = sum + b[i];
      j++;
      i++;
    }
  }
  printf("%lld", sum);
  return 0;
}
