#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k, l;
  while (cin >> n >> k >> l) {
    for (int i = 1; i <= n * k; i++) cin >> a[i];
    sort(a + 1, a + n * k + 1);
    if (a[n] - a[1] > l) {
      cout << 0 << endl;
      continue;
    } else {
      long long sum = 0;
      long long h = a[1] + l;
      int p = ((upper_bound(a + 1, a + n * k + 1, h)) - a) - 1;
      int cnt = 0, q = p;
      for (int j = n * k; j - (k - 1) > p; j -= (k - 1)) {
        sum += a[q--];
        cnt++;
      }
      for (int i = 1; i <= p - cnt; i += k) sum += a[i];
      cout << sum << endl;
    }
  }
  return 0;
}
