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

int main(void)
{
	int n, m, p[10000];
	while (cin >> n >> m)
	{
		if (n == 0 && m == 0) break;
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> p[i];
			sum += p[i];
		}
		sort(p, p + n);
		for (int i = n - m; i >= 0; i -= m) sum -= p[i];
		cout << sum << endl;
	}
}