#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k, l, m, i, x = 0, t = 0;
  long long ans = 0;
  cin >> n >> k >> l;
  m = n * k;
  for (i = 0; i < m; ++i) cin >> a[i];
  sort(a, a + m);
  for (i = m - 1; i >= 0; --i) {
    if (a[i] - a[0] > l) {
      x++;
      continue;
    }
    if (x >= k - 1) {
      x -= (k - 1);
      ans += a[i];
      t++;
    } else
      x++;
  }
  if (t != n)
    cout << "0\n";
  else
    cout << ans << "\n";
}
