#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
double pi = 3.1415926535898;
string ys = "YES\n";
string no = "NO\n";
const double EPS = 1e-6;
const int inf = 1 << 30;
const long long M = 1e9 + 7;
const int N = 100100;
long long n, l, k;
long long a[N];
long long s, m;
long long cnt, ok;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> k >> l;
  m = k * n;
  for (int i = 0; i <= int(m - 1); ++i) {
    cin >> a[i];
  }
  sort(a, a + m);
  for (int i = m - 1; i >= 0; i--) {
    if (a[i] - a[0] > l) {
      ++cnt;
      continue;
    }
    if (cnt >= k - 1) {
      cnt -= k - 1;
      ok++;
      s += a[i];
    } else {
      cnt++;
    }
  }
  if (ok != n) s = 0;
  cout << s;
}
