#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long v[N];
int main() {
  int n, k, l;
  cin >> n >> k >> l;
  for (int i = 1; i <= n * k; i++) cin >> v[i];
  sort(v + 1, v + n * k + 1);
  int p = n * k + 1;
  for (int i = 2; i <= n * k; i++)
    if (v[i] - v[1] > l) {
      p = i;
      break;
    }
  p--;
  if (p < n) {
    cout << 0;
    return 0;
  }
  long long ans = v[1];
  int took = 0;
  for (int i = p; i > 1; i--) {
    if (n * k - i - took >= k - 1) {
      took += k;
      ans += v[i];
    }
    if (took == (n - 1) * k) break;
  }
  cout << ans;
}
