#include <bits/stdc++.h>
using namespace std;
const long long N = 111111;
long long a[N];
long long n, k, l;
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> l;
  for (long long i = 1; i <= n * k; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n * k + 1);
  long long pos;
  for (pos = 1; pos <= n * k && a[pos] - a[1] <= l; pos++)
    ;
  pos--;
  long long ans = 0, cur = n;
  for (long long i = n * k; i >= 1; i--) {
    long long maxi = min(pos, cur * k - k + 1);
    if (i <= maxi) {
      ans += a[i];
      cur--;
      if (cur == 0) {
        break;
      }
    }
  }
  if (cur) {
    ans = 0;
  }
  cout << ans << "\n";
  return 0;
}
