#include <bits/stdc++.h>
using namespace std;
long long n, k, l;
long long len[100005];
int vis[100005];
int main() {
  while (~scanf("%lld %lld %lld", &n, &k, &l)) {
    long long m = n * k;
    for (long long i = 0; i < m; i++) scanf("%lld", &len[i]);
    sort(len, len + m);
    int t = upper_bound(len, len + m, len[0] + l) - len;
    if (n / k == 1 || t < n) {
      cout << 0 << endl;
      continue;
    }
    memset(vis, 0, sizeof vis);
    int idx = 0;
    stack<int> que;
    for (int i = 1; i <= n; i++) que.push(t - i);
    long long ans = 0, flag = 0;
    for (int i = 0; i < n; i++) {
      if (flag)
        ans += len[que.top()];
      else
        ans += len[idx];
      que.pop();
      for (int j = 0; j < k; j++) {
        if (que.size() && idx != que.top())
          idx++;
        else if (flag == 0)
          flag = 1, idx = t;
        else
          idx++;
      }
    }
    cout << ans << endl;
  }
}
