#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int n, k, l;
int main() {
  cin >> n >> k >> l;
  for (int i = 0; i < n * k; i++) cin >> arr[i];
  sort(arr, arr + n * k);
  vector<int> got, can;
  for (int i = 0; i < n * k; i += k) got.push_back(arr[i]);
  for (int i = 0; i < n * k; i++) {
    if (i % k == 0) continue;
    if (arr[i] - arr[0] <= l) can.push_back(arr[i]);
  }
  int cur = can.size() - 1;
  for (int i = got.size() - 1; i >= 0; i--) {
    if (got[i] - arr[0] > l) {
      if (cur < 0) {
        cout << 0 << endl;
        return 0;
      }
      got[i] = can[cur];
      cur--;
    }
  }
  long long ans = 0;
  for (int i = 0; i < got.size(); i++) ans += got[i];
  cout << ans << endl;
}
