#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, l, a[100005];
bool taken[100005];
int main() {
  scanf("%lld %lld %lld", &n, &k, &l);
  m = n * k;
  for (int i = 0; i < m; i++) scanf("%lld", &a[i]);
  sort(a, a + m);
  long long int x = upper_bound(a, a + m, a[0] + l) - a;
  if (x < n) {
    cout << 0 << endl;
    return 0;
  }
  stack<long long int> stk;
  long long int ans = 0;
  int j = 0;
  int extra = 0;
  for (int i = 0; i < x; i++) {
    if (!extra || x - i <= n) {
      ans += a[i];
      taken[i] = 1;
      n--;
      extra += k - 1;
    } else
      extra--;
  }
  cout << ans << endl;
}
