#include <bits/stdc++.h>
using namespace std;
const int N = 123456;
int n, k, l, a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> l;
  for (int i = 1; i <= n * k; i++) cin >> a[i];
  sort(a + 1, a + n * k + 1);
  int r = 2;
  while (r <= n * k && a[r] - a[1] <= l) r++;
  r--;
  if (r < n) {
    cout << 0 << '\n';
    return 0;
  }
  long long ans = 0;
  int cnt = 0, i;
  for (i = 1; r - (i + k) + 1 >= n - cnt; i += k) {
    ans += a[i];
    cnt++;
  }
  ans += a[i];
  cnt++;
  for (int j = r; cnt < n; cnt++) ans += a[j--];
  cout << ans << '\n';
  return 0;
}
