#include <bits/stdc++.h>
using namespace std;
unsigned long long int n, k, l, s[100001], x, a;
int bin(int b, int e) {
  if (b == e) return e;
  int mid = (b + e) / 2;
  int r = s[mid] - s[0];
  if (r == l) return mid;
  if (s[mid + 1] - s[0] > l && r < l) return mid;
  if (r > l) return bin(b, mid);
  return bin(mid + 1, e);
}
int main() {
  cin >> n >> k >> l;
  for (int i = 0; i < n * k; i++) {
    cin >> s[i];
  }
  sort(s, s + k * n);
  if ((s[n - 1] - s[0]) > l) {
    cout << 0;
    return 0;
  }
  int h = bin(1, n * k - 1);
  while (s[h] == s[h + 1]) h++;
  n--;
  for (int i = 1; i <= h; i++) {
    if (h - n + 1 <= i) {
      x += s[i];
      n--;
    } else {
      if (i - a + 1 == k) {
        a = i + 1;
        x += s[i + 1];
        n--;
      }
    }
  }
  cout << x + s[0];
  return 0;
}
