#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int n, m, k, pl, sum;
long long ans = 0, a[N], d;
int main() {
  scanf("%d%d%lld", &n, &k, &d);
  m = n * k;
  for (int i = (1); i <= (m); i++) scanf("%lld", &a[i]);
  sort(a + 1, a + m + 1);
  int dum = 0, pl = m;
  for (int i = (1); i <= (m); i++)
    if (a[1] + d < a[i]) {
      pl = i - 1;
      break;
    }
  sum = m - pl;
  for (int i = (pl); i >= (1); i--) {
    if (sum >= k - 1)
      ans += a[i], sum -= k - 1, dum++;
    else
      sum++;
  }
  printf("%lld", dum == n ? ans : 0);
  return 0;
}
