import sys

f = sys.stdin





while True:

    n, m = list(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))
while True:

    n, m = list(map(int, input().split()))

    if n == 0:

        break

    price = sorted(map(int, input().split()), reverse=True)

    print((sum(price) - sum(price[m - 1::m])))
import sys

f = sys.stdin
while True:
    n, m = list(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))

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

-import sys - -f = sys.stdin -    n, m = list(map(int, f.readline().split())) +    n, m = list(map(int, input().split())) -    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)) +    price = sorted(map(int, input().split()), reverse=True) +    print((sum(price) - sum(price[m - 1 :: m])))