N, K = list(map(int, input().split()))

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



cnt = 0

atk = 0

while True:

    for i in range(N):

        if H[i] <= 0:

            continue

        else:

            if K > 0:

                K -= 1

                H[i] = 0

                cnt += 1

            else:

                atk += H[i]

                cnt += 1



    if cnt == N:

        break



print(atk)
N, K = list(map(int, input().split()))

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



atk = 0

for i in range(N):

    if K > 0:

        K -= 1

    else:

        atk += H[i]



print(atk)
N, K = list(map(int, input().split()))
H = sorted(list(map(int, input().split())), reverse=True)
cnt = 0
atk = 0
while True:
    for i in range(N):
        if H[i] <= 0:
            continue
        else:
            if K > 0:
                K -= 1
                H[i] = 0
                cnt += 1
            else:
                atk += H[i]
                cnt += 1
    if cnt == N:
        break
print(atk)

N, K = list(map(int, input().split()))
H = sorted(list(map(int, input().split())), reverse=True)
atk = 0
for i in range(N):
    if K > 0:
        K -= 1
    else:
        atk += H[i]
print(atk)

-cnt = 0 -while True: -    for i in range(N): -        if H[i] <= 0: -            continue -        else: -            if K > 0: -                K -= 1 -                H[i] = 0 -                cnt += 1 -            else: -                atk += H[i] -                cnt += 1 -    if cnt == N: -        break +for i in range(N): +    if K > 0: +        K -= 1 +    else: +        atk += H[i]