#include <bits/stdc++.h>
int n, k, l, m, tot, a[100005];
bool vis[100005];
long long ans;
int main() {
  scanf("%d%d%d", &n, &k, &l);
  m = n * k;
  for (int i = 1; i <= m; ++i) scanf("%d", &a[i]);
  std::sort(a + 1, a + m + 1);
  for (int i = 1; i <= m && a[i] - a[1] <= l; i += k)
    tot++, vis[i] = 1, ans += a[i];
  for (int i = m; i && tot < n; --i)
    if (a[i] - a[1] <= l && !vis[i]) tot++, vis[i] = 1, ans += a[i];
  printf("%I64d\n", tot == n ? ans : 0ll);
}
