#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  for (x = c - '0'; (c = getchar()) >= '0' && c <= '9';) x = x * 10 + c - '0';
  return x;
}
int a[100000 + 5];
int main() {
  int n, k, l, i, x;
  long long ans = 0;
  n = read();
  k = read();
  l = read();
  for (i = 1; i <= n * k; ++i) a[i] = read();
  sort(a + 1, a + n * k + 1);
  x = upper_bound(a + 1, a + n * k + 1, a[1] + l) - a - 1;
  if (x < n) return 0 * puts("0");
  for (i = 1; i <= n; ++i) ans += a[min(x - i + 1, (n - i) * k + 1)];
  cout << ans;
}
