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