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: while 1:
    n, m = map(int, input().split())
    if n == 0:
        break

    veg = list(map(int, input().split()))
    veg.sort(reverse=True)

    cnt = 0
    ans = 0
    while veg != []:
        cnt += 1
        tmp = veg.pop(0)
        if cnt % m == 0:
            pass
        else:
            ans += tmp

    print(ans)

Python: # -*- coding: utf-8 -*-
"""
Thanksgiving
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0227

"""
import sys


def solve(n, m, prices):
    ans = 0
    for i in range(0, n, m):
        t = prices[i:i+m]
        if len(t) == m:
            t[-1] = 0
        ans += sum(t)
    return ans


def main(args):
    while True:
        n, m = map(int, input().split())
        if n == 0 and m == 0:
            break
        prices = sorted([int(p) for p in input().split()], reverse=True)
        ans = solve(n, m, prices)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: while 1:
	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: while True:
  n, m = map(int, input().split())
  if n == 0:
    break
  plst = sorted(list(map(int, input().split())), reverse=True)
  s = sum(plst)
  for i in range(m - 1, n, m):
    s -= plst[i]
  print(s)

Python: while True:
    try:
        __, m = (lambda row: [int(row[i]) for i in range(len(row))])(input().split())
        price = sorted(list(map(int, input().split())), reverse=True)
        print(str(sum([price[i] for i in range(len(price)) if (i+1)%m != 0])))
    except:
        break

Python: while True:
    a = input()
    print('a')

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 xrange(n[0]):
        if (i + 1) % n[1] != 0:
            sum += data[i]
    #     print(i)

    print(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:
    a = input()
    print('a')

Python: while True:
    n,m = map(int,raw_input().split(' '))

Python: while 1:
    _,m=map(int, input().split())
    if m==0:break
    p=sorted(map(int,input().split()),reverse=1)
    print(sum(p)-sum(p[m-1::m]))

Python: print(1)

Python: while True:
    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)

Python: # -*- coding: utf-8 -*-

while 1:
  try:
    n, m = map(int, input().split())
    if n == 0:
      break
    p = sorted(list(map(int, input().split())))
    p.reverse()
    for i in range(m - 1, n, m):
      p[i] = 0
    print(sum(p))
  except:
    break

Python: while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    price = sorted(map(int, input().split()), reverse=True)
    print(sum(price) - sum(price[m - 1::m]))

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: 
while True:
    try:
        num, size = map(int, input().split())
        arr = list(map(int, input().split()))
        arr.sort(reverse = True)
        for i in range(size-1, num, size):
            arr[i] = 0
        print(sum(arr))
    except:
        break

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


    print(1)

Python: while True:
    n,m = map(int,raw_input().split())

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


    print(1)

Python: while True:
    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:]:
        pass

    print(s)

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

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
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

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())) 
    print(amari)

Python: while 1:
    n=map(int, raw_input().split())
    if n[0]==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: # Aizu Problem 0227: Thanksgiving

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")



while True:
    n, m = [int(_) for _ in input().split()]
    if n == m == 0:
        break
    prices = sorted([int(_) for _ in input().split()], reverse=True)
    for i in range(m - 1, n, m):
        prices[i] = 0
    print(sum(prices))

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


    print(1)

Python: while 1:
      qua,bag = input().split()
      qua = int(qua)
      bag = int(bag)
      if qua == 0:
            break
      price = list(map(int,input().split()))
      price.sort(reverse=True)
      for i in range(qua):
            if (i+1)%bag == 0:
                  price[i]=-1
      for i in range(qua//bag):
            price.remove(-1)
      pay = sum(price)
      print(pay)

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: 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(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