Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"sort"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		n, _ := strconv.Atoi(buf[0])
		m, _ := strconv.Atoi(buf[1])
		if n == 0 && m == 0 {
			break
		}
		scanner.Scan()
		buf_ := strings.Split(scanner.Text(), " ")
		items := make([]int, n)
		for i := 0; i < n; i++ {
			items[i], _ = strconv.Atoi(buf_[i])
		}
		sort.Ints(items)
		sum := 0
		for _, v := range items {
			sum += v
		}
		for i := n-m; i >= 0; i -= m {
			sum -= items[i]
		}
		fmt.Println(sum)
	}
}

Python: # AOJ 0227: Thanksgiving
# Python3 2018.6.24 bal4u
 
while 1:
    n, m = map(int, input().split())
    if n == 0: break
    p = list(map(int, input().split()))
    p.sort(reverse=True)
    ans = 0
    for i in range(1, n+1):
        if i % m: ans += p[i-1]
    print(ans)

Python: while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        if amari > 0:
            s = sum(yasai[0:amari])

        i = 0
        for y in yasai[amari:]:
            if i % m > 0:
                s += y
            i+=1

        print(s)
    except:
        pass

Python: while True:

    n, m = [int(i) for i in input().split()]
    if n == 0 and m == 0:
        break

    p = [int(i) for i in input().split()]
    p.sort()
    p.reverse()

    ans = 0
    for i in range(len(p)):
        if (i+1) % m > 0:
            ans = ans + p[i]

    print(ans)

Python: while True:
    n = map(int, raw_input().split())
    if n[0] == 0 and n[1] == 0:
        break
    # print(n)
    data = sorted(map(int, raw_input().split()), reverse = True)
    # print(data)   
    sum = 0

    for i in range(n[0]):
        if (i + 1) % n[1] != 0:
            sum += data[i]
    #     print(i)

    print(sum)

Python: def main():

    while True:
        n  =  map(int,  raw_input().split())
        if n[0]  ==  0 and n[1]  ==  0:
            break
        # print(n)
        data  =  sorted(map(int,  raw_input().split()),  reverse  =  True)
        # print(data)   
        sum  =  0

        for i in range(len(data)):
            if (i  +  1 )  %  n[1] !=  0:
                sum += data[i]
        #     print(i)

        print(sum)

if __name__ == '__main__':
    main()

Python: while True:
    #n,m = list(map(int,input().split()))
    #spam = input()


    print(1)

Python: while True:
    n,m = list(map(int,input().split()))
    if n == 0 and m == 0:
        break

    amari = int(n % m)
    yasai = list(map(int,input().split())) 
    yasai.sort()

    s = 0
    if amari > 0:
        s = sum(yasai[0:amari])

    i = 0
    for y in yasai[amari:]:
        pass
        if i % m > 0:
            s += y
        i+=1

    print(s)

Python: while True:
	n,m=map(int, raw_input().split())
	if n==0:break
	c=sorted(map(int,raw_input().split()))[::-1]
#	if m > n:
#		print sum(c)
#	else:
#		c[m-1::m] = [0 for i in range(m-1,n,m)]
#		print sum(c)

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    n,m = map(int,input().split(" "))
    if n == 0 and m == 0:
        break
    prices = list(map(int,input().split(" ")))
    count = 0
    cost = 0
    for p in reversed(sorted(prices)):
        count += 1
        if count >= m:
            count = 0
            continue
        else:
            cost += p
    print(cost)

Python: import sys
f = sys.stdin


while True:
    n, m = map(int, f.readline().split())
    if n == 0:
        break
    vegitables = sorted(map(int, f.readline().split()), reverse=True)
    discount = sum(vi for i, vi in enumerate(vegitables) if (i + 1) % m == 0)
    print(sum(vegitables) - discount)

Python: for i in range(1, 101):
    count = 0
    SetCount = 0

    try:
        str1 = input()
        list1 = str1.split(" ")
        str2 = input()
        list2 = str2.split(" ")
        list2.sort(reverse=True)
        for m in range(0, int(list1[0])):
            if (m+1) % int(list1[1]) == 0:
                count = count + int(list2[m])
                SetCount = SetCount + 1
            elif (m+1) % int(list1[1]) != 0 | SetCount == int(list1[0])//int(list1[1]):
                count = count + int(list2[m])
        print(count)

    except:
        break

Python: for i in range(1, 101):
    count = 0
    temp = 0
    SetCount = 0

    try:
        str1 = input()
        list1 = str1.split(" ")
        str2 = input()
        list2 = str2.split(" ")
        list2.sort(key=int, reverse=True)
        for m in range(0, int(list1[0])):
            if (m+1) % int(list1[1]) == 0:
                SetCount = SetCount + 1
            #elif (m+1) % int(list1[1]) != 0 | SetCount == int(list1[0])//int(list1[1]):
             #   count = count + int(list2[m])
            else:
                count = count + int(list2[m])
        print(count)

    except:
        break

Python: while True :
    n, m = map(int, input().split())
    if n == 0 and m == 0 :
        break
    
    p = list(map(int, input().split()))
    p.sort(reverse=True)
    cst = 0
    for i in range(n) :
        if (i+1) % m != 0 :
            cst += p[i]
    print(cst)

Python: while True:
    n,m = map(int,raw_input().split())
    if n == 0 and m == 0:
        break

    amari = n % m
    yasai = map(int,raw_input().split())
    yasai.sort()

    s = 0
    if amari > 0:
        s = sum(yasai[0:amari])

    i = 0
    for y in yasai[amari:]:
        if i % m > 0:
            s += y
        i+=1

    print(s)

Python: while True:
    n = map(int, raw_input().split())
    if n[0] == 0 and n[1] == 0:
        break
    data = sorted(map(int, raw_input().split()), reverse = True)
    sum = 0

    for i in xrange(n[0]):
        if (i + 1) % n[1] != 0:
            sum += data[i]

    print(sum)

C++: #include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	
	while (scanf("%d %d", &n, &m), n != 0 && m != 0){
		
		int p[1024];
		
		for (int i = 0; i < n; i++){
			scanf("%d", &p[i]);
		}
		
		sort(p, p+n);
		reverse(p, p+n);
		
		for (int i = 0; i < n; i++){
			if ((i + 1) % m == 0){
				p[i] = 0;
			}
		}
		
		int sum = 0;
		for (int i = 0; i < n; i++){
			sum += p[i];
		}
		
		printf("%d\n", sum);
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main(){
    int n,m,x;
    int flag = 0;
    int num = 0;
    std::vector<int> v;
    
    std::cin >> n >> m;
    
    while(std::cin >> x){
        v.push_back(x);
    }
    
    sort(v.rbegin(),v.rend());
    
    for(int y = 0;y < n;++y){
        flag++;
        if(flag != m){
            num += v[y];
        }
        else
             flag = 0;
    }
    std::cout << num << std::endl;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int a,b,i,sum=0;
	int c[a];
	while(1){
		cin >> a >> b;
		if(a==0 && b==0) break;
		for(i=0;i<a;i++){
			cin >> c[i];
			sum+=c[i];
		}
		sort(c,c+a);
		reverse(c,c+a);
		for(i=b-1;i<a;i+=b){
			sum-=c[i];
		}
		cout << sum << endl;
		sum=0;
	}
	

	return 0;
}