#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
long long a[N];
int main() {
  int n, k, l, m;
  cin >> n >> k >> l;
  m = n * k;
  for (int i = 0; i < m; i++) cin >> a[i];
  sort(a, a + m);
  int r = 0;
  while (r < m && (a[r] - a[0]) <= l) r++;
  if (r < n) {
    cout << 0;
    return 0;
  }
  r--;
  long long res = a[0];
  int left = 0, count = 1, i = 0;
  while (count < n) {
    i++;
    if (i - left == k || (r - i + 1) == (n - count)) {
      res += a[i];
      count++;
      left = i;
    }
  }
  cout << res;
  return 0;
}
