#include <iostream>
#include <vector>
#include <algorithm>
int main() {
	int n, m;
	std::cin >> n >> m;
	while (n != 0 && m != 0) {
		int whole_price = 0;
		std::vector<int> vegi(n);
		for (auto &v : vegi) std::cin >> v;
		std::sort(vegi.begin(), vegi.end());
		for (auto i = 1; i <= n; ++i) {
			whole_price += (i % m == 0) ? 0 : vegi[n - i];
		}
		std::cout << whole_price << std::endl;
		std::cin >> n >> m;
	}
}

#include <iostream>
#include <algorithm>
using namespace std;

const int N_MAX = 1000;

int n, m;
int p[N_MAX];

int main () {
	while (cin >> n >> m, n || m) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> p[i];
			sum += p[i];
		}
		sort(p, p + n, greater<int>());
		for (int i = m - 1; i < n; i += m) {
			sum -= p[i];
		}
		cout << sum << endl;
	}
	return 0;
}