#include <bits/stdc++.h>
using namespace std;
long long n, k, l, ans = 0, m;
long long a[100005];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> l;
  m = n * k;
  for (int i = 1; i <= m; ++i) cin >> a[i];
  sort(a + 1, a + m + 1);
  for (int i = m; i > 1; --i) {
    if (a[i] - a[1] > l)
      --m;
    else
      break;
  }
  if (m < n) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= m; ++i) {
    ans += a[i];
    --n;
    int nxt = i + k;
    if (m - nxt + 1 < n) nxt = m - n + 1;
    i = nxt - 1;
  }
  cout << ans;
  return 0;
}
