#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, k, l;
	cin >> n >> k >> l;
	int m = n*k;
	vector<int> g(1,0);
	int tmp;
	for (int i = 1; i <= m; i++){
		cin >> tmp;
		g.push_back(tmp);
	}
	sort(g.begin(), g.end());
	if (g[n] - g[1]>l) { cout << 0; return 0; }
	int posMaxVol;
	const int maxvol = g[1] + l;  //max volumn

	vector<int>::iterator it;
	if (find(g.begin(), g.end(), maxvol ) != g.end()) {
		it = upper_bound(g.begin(), g.end(), maxvol);
		posMaxVol = it - g.begin() - 1;
	}
	else{
		it = lower_bound(g.begin(), g.end(), maxvol);
		posMaxVol = it - g.begin();
	}

	int cntDu = m - posMaxVol;
	long long ans = 0;
	while (cntDu>0){
		cntDu -= (k - 1);
		ans += g[posMaxVol];
		posMaxVol--;
	}
	for (int i = 1; i <= posMaxVol; i += k){
		ans += g[i];
	}
	cout << ans;

	return 0;
}
