peterverebics/CodeNet_Python_118 huggingface dataset:
"""
Fennec should do special move on the K monsters with largest health.
then the other monsters take H turns to kill.
so total turns is H[i] for i in low health monsters
"""

def calc_num_turns(K, H):
  H.sort(reverse=True)
  total_turns = sum(H[K:])
  return total_turns


if __name__ == "__main__":
  K = int(input().split()[1])
  H = list(map(int, input().split()))
  print(calc_num_turns(K, H))
N, K = map(int, input().split())
H = list(map(int, input().split()))

if len(H)<=K:
    print(0)
else:
    H.sort(reverse=True)
    print(sum(H[K:]))
N,K = map(int,input().split())
H = list(map(int,input().split()))
M = sorted(H)
if N<=K:
    print(0)
else:
    print(sum(M[:N-K]))
n,k = list(map(int,input().split()))
h=list(map(int,input().split()))
h.sort(reverse = True)
print(sum(h[k:]))
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n,k = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

if k<n:
    h.sort()
    print(sum(h[:n-k]))
else:
    print(0)
n,k = map(int,input().split())
h = list(map(int,input().split()))
h = sorted(h,reverse=True)
del h[:k]

print(sum(h))
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())))
if(k==0):print(sum(h))
else:print(sum(h[:-k]))
import sys


def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


N, K = InL()
H = InL()
H.sort()

if K >= N:
    print(0)
    sys.exit()
else:
    print(sum(H[0:N-K]))
def main():
  N, K = map(int, input().split())
  
  H = sorted(list(map(int, input().split())), reverse=True)
 
  n = sum(H)
  
  if K == 0:
    print(n)
  elif N > K:
    for i in range(K):
      n -= H[i]
    print(n)
  else:
    print(0)
    
  return 0
 
if __name__ == "__main__":
  main()
N, K = map(int, input().split())
H = list(map(int, input().split()))

if N <= K:
    print(0)
    exit()
if K == 0:
    print(sum(H))
    exit()


# 大きいやつからK体を0にして，残りは和
H = sorted(H)
total = sum(H)
kill = sum(H[-K:])
print(total - kill)
h, n = [int(x) for x in input().split()]
listk = [int(x) for x in input().split()]
listk.sort()
if n <= h:
    for i in range(0,n):
        listk.pop()
else:
    for i in range(0,h):
        listk.pop()
print(sum(listk))
def fennec_vs_monster():
    # 入力
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    # 体力リストを降順でソート
    H.sort(reverse=True)
    # 体力リストを先頭からK個だけ除外
    H = H[K:]
    # 残りの体力リストを合計
    sum_H = sum(H)
    # 攻撃の回数の最小値
    return sum_H

result = fennec_vs_monster()
print(result)
#n = int(input())
#s = input()
n,m = map(int,input().split())
da = list(map(int,input().split()))

da = sorted(da)

ans = 0
for i in range(n-m):
    ans += da[i]
print(ans)
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
print(sum(H[K:]))
n, k = map(int, input().split())
H = sorted(map(int, input().split()), reverse=True)

ans = 0
while n > k:
  ans += H[k]
  k += 1
else:
  print(ans)
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
ans = 0
if K < N:
  ans = sum(H[K:])
print(ans)
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())))
ans=0
for i in range(max(n-k,0)):
  ans+=h[i]

print(ans)
k = min(map(int,input().split()))
H = sorted(list(map(int,input().split())))
print([sum(H),sum(H[:-k])][k != 0])
import sys

N, K = map(int, next(sys.stdin.buffer).split())
H = list(map(int, next(sys.stdin.buffer).split()))

if K:
  H.sort()
  print(sum(H[:-K]))
else:
  print(sum(H))
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = 0
for i in range(max(0,N-K)):
    ans += H[i]
print(ans)
n,k=map(int,input().split())
*h,=sorted(map(int,input().split()),reverse=1)
for i in range(min(k,n)):
    h[i]=0
print(sum(h))
n,k = input().split()
N = int(n)
K = int(k)
H = [int(x) for x in input().split()]

H.sort(reverse = True)
total = 0
for i in range(N-K):
    total += H[K + i]

print(total)
n,k = map(int,input().split())
h = list(map(int,input().split()))

#降順にソートしたリストを作る
new_h = sorted(h,reverse=True)

#必殺技はカウントしない、攻撃はモンスターの体力を加算
ans = 0
for i in range(n):
    if i <= k-1:
        ans += 0
    else:
        ans += new_h[i]

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

if K >= N:
    print(0)

else:
    H.sort(reverse=True)
    print(sum(H[K:]))
H, K = map(int, input().split())
Hn = list(map(int, input().split()))

ans = 0
Hn.sort()
try:
    for _ in range(K):
        Hn.pop(-1)
except:
    print(0)
    exit()
ans = sum(Hn)
print(ans)
N, K = map(int, input().split())
H = list(map(int, input().split()))
 
# N<=Kの場合、全てのモンスターを必殺技で倒して終了
# N>Kの場合、N体のモンスターのうち、体力が高い順に、K体を必殺技で倒す
# 残ったモンスターは、攻撃によって倒す
# 攻撃の回数を求める（必殺技は数えない）ことに注意する

H = sorted(H, reverse=True)
ans = 0
if N > K: ans = sum(H[K:])
  
print(ans)
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
ans=0
h.reverse()
if k<n:
  for i in range(k,n):
    ans+=h[i]
print(ans)
n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort(reverse=True)
print(sum(h[k:]))
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
reversed(H)
for i in range(K):
  if len(H)==0:
    break
  else:
    H.pop()
if len(H)==0:
  print(0)
else:
  print(sum(H))
H, N = map(int, input().split())
A = list(map(int, input().split()))

# sort
A.sort(reverse=True)
if (len(A) < N):
    print(0)
else:
    print(sum(A[N:]))
n,k=map(int,input().split())
s=list(map(int,input().split()))
s.sort(reverse=True)
del s[:k]
print(sum(s))
N,K=map(int,input().split())
h=list(map(int,input().split()))

H=sorted(h,reverse=True)
if K>=N:
    print(0)
    exit()

Ans=H[K:]
print(sum(Ans))
n,k=map(int,input().split())
h=sorted(list(map(int, input().split())))
if n>=k:
	print(sum(h[0:n-k]))
else:
	print(0)
N, K = map(int, input().split())
H = list(map(int, input().split()))

a = N-K
if a < 0:
    ans = 0
else:
    h = sorted(H)[:a]
    ans = sum(h)
print(ans)
n, k  = map(int, input().split())
nums = list(map(int, input().split()))

nums.sort()
if k != 0:
    ans = sum(nums[:-k])
else:
    ans = sum(nums)
print(ans)
def main():
    n, k = map(int, input().split())
    monsters = sorted(list(map(int, input().split())))

    print(sum(monsters[:-k]) if k != 0 else sum(monsters))


if __name__ == '__main__':
    main()
n,k = map(int,input().split())
h = sorted(list(map(int,input().split())))
ans = 0
if n <= k:
    print(0)
else:
    for i in range(n-k):
        ans += h[i]
    print(ans)
N,K=map(int,input().split())
Hlist=list(map(int,input().split()))
if N-K>0:
    print(sum(sorted(Hlist)[:N-K]))
else:
    print(0)
n,k = map(int,input().split())
h = list(map(int,input().split()))
print(sum(sorted(h)[:n-k]) if n-k>0 else 0)
N, K = (int(x) for x in input().split())
H = [int(x) for x in input().split()]
H.sort()
if N > K:
  S = H[0:N-K]
  print(sum(S))
else:
  print(0)
import sys

n,k = map(int,input().split())
ans = 0;
h = [int(x) for x in input().split()]
h.sort(reverse = True)
h = h[k:]

if len(h) > 0:
    ans += sum(h)

print(ans)
n, k = map(int, input().split())
lst = list(map(int, input().split()))
sor = sorted(lst, reverse=True)
if k >= n:
    print(0)
else:
    new = sor[k:]
    print(sum(new))
n,k = map(int ,input().split())
h=list(map(int ,input().split()))
h.sort(reverse=True)
del h[:k]
print(sum(h))
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
if len(h) <= k:
    print(0)
else:
    for _ in range(k):
        h.pop()
    print(sum(h))
n,k = map(int,input().split())
h = list(map(int,input().split()))

h.sort(reverse=True)

ans = sum(h[min(k,n):n])

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

if K >= N:
    print(0)
    exit()

H = sorted(H)

print(sum(H[0:len(H)-K]))
# N体の敵、K回の必殺技
N, K = map(int, input().strip().split(' '))
N_list = list(map(int, input().strip().split(' ')))
sorted_N = sorted(N_list, reverse=True)

# 必殺技で体力が多い敵からヤる
del sorted_N[:K]

if sorted_N ==[]:
  print(0)
else:
  print(sum(sorted_N))
N, K=map(int, input().split())
H=list(map(int, input().split()))

H.sort(reverse=True)

if K<=len(H):
  print(sum(H[K:len(H)+1]))
else:
  print(0)
n, k = map(int, input().split())
li = list(map(int, input().split()))
ans = 0
kara = []
if n <= k:
  print(ans)
else:
  li.sort(reverse=True)
  x = li[k:]
  ans = sum(x)

  print(ans)
import heapq

n, k = map(int, input().split())
li = list(map(int, input().split()))
li = list(map(lambda x: x * (-1), li))


def attack():
    if n <= k:
        return (0)
    heapq.heapify(li)
    for i in range(k):
        heapq.heappop(li)
    return - 1 * sum(li)


print(attack())
N,K=map(int,input().split())
H=list(map(int,input().split()))
H=sorted(H)

if N<=K:
    print(0)
else:
    print(sum(H[0:N-K]))
n,k = map(int,input().split())
h = list(map(int,input().split()))	
if k >= len(h):
    print(0)
else:
    h.sort(reverse=True)
    print(sum(h[k:]))
n,k=map(int,input().split())
h=list(map(int,input().split()))
s=sorted(h)
s.reverse()
print(sum(s[k:]))
n,k = map(int,input().split())
h_list = list(map(int,input().split()))
h_list.sort(reverse=True)
if k>= len(h_list):
  print(0)
elif k ==0 :
  print(sum(h_list))
else:
  del h_list[:k]
  print(sum(h_list))
n, k = map(int, input().split())
H = list(map(int, input().split()))
H = list(reversed(sorted(H)))
if k >= n:
    print(0)
else:
    print(sum(H[k:]))
n,k = map(int,input().split())
lst = list(map(int,input().split()))

lst.sort()
if k>=n:
    print(0)
else:
    lst.sort()
    cnt = 0
    for i in range(n-k):
        cnt += lst[i]
    print(cnt)
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
if n>k:
  print(sum(h[:n-k]))
else:
  print(0)
N, K = map(int, input().split())
list_H = [int(x) for x in input().split()]

list_H.sort()

while K :
    if list_H :
        list_H.pop()
    K -= 1

print(sum(list_H))
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse = True)

print(sum(h[k : n + 1]))
N, K = map(int, input().split())
H = list(map(int,input().split()))

H.sort(reverse=True)

if N <= K:
    ans = 0
else:
    for i in range(K): H[i] = 0
    ans = sum(H)

print(ans)
n, k = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for i in range(n-k):
    ans += nums[i]
print(ans)
N, K = map(int, input().split())
H = sorted(map(int, input().split()))
print(sum(H[:N-K]) if N>K else 0)
N,K = list(map(int,input().split(" ")))
Hs = list(map(int,input().split(" ")))
Hs.sort()
ans = 0


for i in range(N - K ):
    ans += Hs[i]

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

ld = sorted(l, reverse=True)

print(sum(ld[K:]))
NK = list(map(int, input().split()))
Hi = list(map(int, input().split()))

N = NK[0]
K = NK[1]
Hi.sort()
reversed_Hi = list(reversed(Hi))

for i in range(len(reversed_Hi)):
    if not reversed_Hi:
        break

    if K == 0:
        break
    else:
        K -= 1
        reversed_Hi[i] = 0

count = 0
for i in reversed_Hi:
    count += i

print(count)
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = sum(H[0:max(0,N-K)])
print(ans)
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())))[::-1]
print(sum(H[K:]))
x = input().split()
N, K = [int(i) for i in x]
H = input().split()
Hi = [int(j) for j in H]
Hi.sort(reverse=True)
num = Hi[K:]
print(sum(num))
import sys
n,k=map(int,input().split())
h=list(map(int,input().split()))

if n<=k:
  print(0)
  sys.exit()

hi=sorted(h)
if k:
  print(sum(hi[:-k]))
else:
  print(sum(hi))
n,k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse = True)
count = 0
for i in range(k,n):
    count += h[i]
print(count)
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]

if N <= K:
    print(0)
else:
    H.sort()
    print(sum(H[:N-K]))
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
if K >= N:
    print(0)
else:
    print(sum(A[K:]))
H,N = list(map(int,input().split(" ")))
A = list(map(int,input().split(" ")))
total = 0
A.sort(reverse=True)
del A[:N]
for i in A:
  total +=i
print(total)
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
sum=0
for h in H[K:]:
    sum+=h

print(sum)
N, K = map(int, input().split())
H = list(map(int, input().split()))
size=len(H)
if N<=K:
  ret=0
else: 
  H.sort()
  ret=max(0, sum(H)-sum(H[size-K:]))

print( ret )
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())), reverse=True)

print(sum(h[k:]))
n,k = map(int,input().split())
s = list(map(int,input().split()))
s.sort()
if k == 0:
  print(sum(s))
elif n >= k:
  del s[-k:]
  print(sum(s))
else:
  print(0)
n, k = map(int, input().split())
h = [int(x) for x in input().split()]
h = sorted(h, reverse=True)
if k < n:
    ans = sum(h[k:])
else:
    ans = 0
print(ans)
a,b = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
for i in range(b):
    if N:
        N.pop()
print(sum(N))
n,k = map(int,input().split())
li = list(map(int,input().split()))
ls = sorted(li, reverse=True)
if k >= len(li):
    print(0)
else:
    print(sum(ls[k:]))
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
if K==0:
  print(sum(H))
else:
  print(sum(H[:-K]))
n,k = map(int,input().split())
h_lst = list(map(int,input().split()))

if n<=k:
    number = 0
elif 0<k<n:
    h_lst.sort()
    number = sum(h_lst)-sum(h_lst[-k:])
elif k==0:
    number = sum(h_lst)

print(number)
a, b = map(int, input().split())
array = list(map(int, input().strip().split()))
array_sort = sorted(array)
out = 0 if a <= b else sum(array_sort[0:a-b])
print(out)
N,K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H, reverse = True)
H = H[K:N]
print(sum(H))
N,K = map(int,input().split())
Hli = list(map(int,input().split()))

Hli.sort(reverse = True)
res = 0

for i in range(K,N):
  res += Hli[i]

print(res)
n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort(reverse=True)

print(sum(h[k:]))
n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
  print('0')
else:
  h.sort()
  for i in range(k):
    h.pop()
  print(sum(h))
n,k,*h=map(int,open(0).read().split())
h=sorted(h)[::-1]
for i in range(min(k,n)):h[i]=0
print(sum(h))
N,K = map(int, input().split())
H = list(map(int, input().split()))
if K >= N:
    print(0)
    exit()

H.sort(reverse=True)
print(sum(H[K:]))
N,K = list(map(int,input().split()))
H = list(map(int,input().split()))

H.sort(reverse=True)

ans = 0
for i in range(K,N):
    ans += H[i]

print(ans)
b,k=map(int,input().split())
h=list(map(int,input().split()))
h=sorted(h)
if k==0:
    print(sum(h))
else:
    print(sum(h)-sum(h[-k:]))
a, k = list(map(int, input().split()))
H = list(map(int, input().split()))
if len(H) <= k:
  print(0)
else:
  print(sum(sorted(H)[:len(H)-k]))
import sys

n, k = map(int, input().split())
h = list(map(int, input().split()))

if k >= n:
    print(0)
    sys.exit()

h.sort()
print(sum(h[:n-k]))
N, K = map(int, input().split())
HP = list(map(int, input().split()))
HP = sorted(HP)

if K != 0:
  HP_killed = HP[:-K]
  print(sum(HP_killed))
else:
  HP_killed = HP
  print(sum(HP_killed))
s = []
for i in range(2):
    s.append(input().split())
n = int(s[0][0])
k = int(s[0][1])
answer = 0
hs = s[1]
h = [int(a) for a in hs]
h.sort()
h.reverse()
if(k<n):
    for i in range(k,n):
        answer = answer + h[i]
print(answer)
n, k = map(int, input().split())
h = list(map(int, input().split()))
list.sort(h, reverse=True)
if k >= len(h):
  print(0)
  exit()
else:
  print(sum(h[k:]))
N, K = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort(reverse=True)
ans = 0

if N <= K:
  print(0)
else:
  print(sum(lst[K:]))
n,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
if k!=0:
    print(sum(H[:-k]))
else:
    print(sum(H))
N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort()
print(sum(H[:max(N-K, 0)]))
N, K = (int(x) for x in input().split())
H = list(map(int, input().split()))

if N <= K:
    print(0)
else:
    H.sort()    
    print(sum(H[0:N-K]))
N, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)
print(sum(A[K:]))
from sys import stdin
H,K = [int(x) for x in stdin.readline().rstrip().split()]
H = [int(x) for x in stdin.readline().rstrip().split()]
print(sum(sorted(H)[::-1][K:]))
n, k = map( int, input().split() )
h = list( map( int, input().split() ) )

h.sort()
print( sum( h[ : max( n - k, 0 ) ] ) )
N, K = (int(nk) for nk in input().split())
H = [int(h) for h in input().split()]

H = sorted(H, reverse=True)[K:]

print(sum(H))
n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort(reverse = True)
print(sum(h[k:]))
# -*- coding: utf-8 -*-
"""
Created on Fri May  8 15:19:53 2020

@author: shinba
"""
from sys import exit

n,k = map(int,input().split())
h = list(map(int,input().split()))

if k >= len(h):
    print(0)
    exit()
    
h.sort()

while k > 0:
    h.pop()
    k -= 1

print(sum(h))
import bisect
import numpy as np
import math
import itertools
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    if N <= K:
        print(0)
    elif K == 0:
        print(sum(H))
    else:
        H = sorted(H)
        H = H[:-K]
        print(sum(H))


    return 0
if __name__ == '__main__':
    main()
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n, k = MI()

h = FLI()
h.sort(reverse = True)
print(sum(h[k:]))
N,K=map(int,input().split())
ar= list(map(int, input().split()))
ans=0
ar.sort()

if N<=K:
    print(ans)
else:
    for i in range(1,K+1):
        f=-1*i
        ar[f]=0

    for i in range(N):
        ans+=ar[i]

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

HP = sum(H)
ld = sorted(H , reverse=True)
if K >= len(H):
    print(0)

else:
    Z = sum(ld[:K])
    hp = HP - Z
    print(hp)
N, K = map(int, input().split())
List = [int(x) for x in input().split()]

if K == 0:
    print(sum(List))
    exit()

if N <= K:
    print('0')
    exit()

List.sort(reverse=True)
del List[:K]

print(sum(List))
n, k = [int(i) for i in input().split(" ")]
h = [int(i) for i in input().split(" ")]
h = sorted(h)
sum_v = 0

for i in range(n-k):
    sum_v += h[i]
    
print(sum_v)
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
H.reverse()
print(sum(H[K:]))
hn=input().split(" ")
N=int(hn[0])
K=int(hn[1])
H=input().split(" ")
H=[int(s) for s in H]
H.sort(reverse=True)
#print(H)
ans=0
for i in range(N):
    if K>0:
        K-=1
    else:
        ans+=H[i]

print(ans)
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
ans = 0
for i in range(min(k, len(h))):
    h[i] = 0
print(sum(h))
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

h,k = map(int, input().split())
h = np.array(sorted(list(int(i) for i in input().split()), \
      reverse = True))

print(h[k:].sum())
N, K = list(map(lambda n: int(n), input().split(" ")))
HP = list(map(lambda hp: int(hp), input().split(" ")))
HP.sort(reverse=True)

if K >= len(HP):
  print(0)
else:
  print(sum(HP[K:]))
N, K = map(int, input().split())
H = list(map(int,input().split()))

H.sort(reverse=True)
print(sum(H[K:]))
N,K = map(int,input().split())
H = list(map(int,input().split()))
if K == 0:
  print(sum(H))
else:
  H.sort(reverse = True)
  if N>K:
    h = H[K:N]
    print(sum(h))
#    for i in range(K):
 #     del H[i]
  #  print(sum(H))
  else:
    print(0)
n, k = map(int, input().split())
h = sorted(map(int, input().split()), reverse=True)
if k == 0:
    print(sum(h))
elif k < n:
    print(sum(h[k:]))
else:
    print(0)
N, K = map(int, input().split())
H = sorted(list(map(int,input().split())))
ans =0

if K >= N:
  ans = 0
else:
  ans = sum(H[:N-K]) 
print( ans)
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
if k >= n:
  print(0)
else:
  print(sum(a[k:]))
n,k = map(int,input().split())
a = list(map(int,input().split()))
if n <= k:
  print(0)
else:
  a.sort()
  print(sum(a[:n-k]))
def main():
    n,k=map(int,input().split())
    h = list(map(int,input().split()))

    h.sort()
    if k >= n:
        print(0)
        return
    for i in range(1,k+1):
        h.pop(-1)
    print(sum(h))
if __name__=='__main__':
    main()
N, K = map(int,input().split())
monsters = [int(i) for i in input().split()]
monsters.sort(reverse=True)
deleted_monsters = []
for i in range(N):
    if i < K:
        deleted_monsters.append(0)
    else:
        deleted_monsters.append(monsters[i])
print(sum(deleted_monsters))
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
if K<N:
    print(sum(H[0:N-K]))
else:
    print(0)
import sys
n, k = map(int, input().split())
H = list(map(int, input().split()))

H = sorted(H)
if k >= n:
  print(0)
  sys.exit()

cnt = 0
for i in range(n-k):
  cnt += H[i]
print(cnt)
n,k=map(int,input().split())
h=[int(i) for i in input().split()]

h.sort()

if n > k:
    ans=sum(h[:n-k])
else:
    ans=0
    
print(ans)
n,k = map(int,input().split())
l = [int(i) for i in input().split()]
ls = sorted(l)
if k == 0:
  print(sum(l))
else:
  print(sum(ls[:-k]))
N,K=map(int,input().split())
H=sorted(map(int,input().split()))
if K==0:
    print(sum(H))
elif N<K:
    K=N
    del H[-K:]
    print(sum(H))
else:
    del H[-K:]
    print(sum(H))
n,k = map(int,input().split())
h = list(map(int,input().split()))
total = 0
h.sort(reverse=True)
for i in range(k,n):
    total += h[i]
print(total)
n,k=map(int,input().split())
h=list(map(int,input().split()))

h.sort(reverse=True)

if k>n:
  k=n

for i in range(k):
  h[i]=0

sum_=0
for hh in h:
  sum_+=hh
print(sum_)
import math
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
a.reverse()
print(sum(a[k:]))
N, K = map(int, input().split())
list02 = sorted(map(int, input().split()), reverse=True)
print(sum(list02[K:]))
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse = True)
if k > n:
	k = n
for i in range(k):
	h[i] = 0
print(sum(h))
n,k=map(int,input().split())
s=list(map(int,input().split()))

if n<=k:
  print(0)
elif k==0:
  print(sum(s))
else:
  s.sort()
  print(sum(s[0:-k]))
n, k = map(int, input().split())
h = list(map(int, input().split()))

if k >= n:
    mini = 0
else:
    h.sort(reverse=True)
    mini = 0
    for i in range(k, n):
        mini += h[i]
print(mini)
n, k = [int(i) for i in input().split()]
h = [int(j) for j in input().split()]

if(n<=k):
  print(0)
  exit()
else:
  h = sorted(h)
  del h[n-k:n]
  print(sum(h))
def solve():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    sortedH = sorted(H, reverse=True)
    print(sum(sortedH[K:]))

if __name__ == '__main__':
    solve()
import sys

I = list(map(int, input().split()))
H_i = list(map(int,input().split()))
H_i = [i for i in H_i if 1 <= i and i <= 10**9]
N = I[0] # Monster数
K = I[1] # 必殺技回数

if not 0 <= K or not K <= 2*10**5 or not 1 <= N or not N <= 2*10**5:
    print("error")
    sys.exit()

H_i = sorted(H_i, reverse=True) # 降順ソート
H_i = H_i[K:]
ans = sum(H_i)
print(ans)
N, K = map(int, input().split())
monster_hp_list = list(map(int, input().split()))
monster_hp_list = sorted(monster_hp_list)

for i in range(K):
    if len(monster_hp_list) >= 1:
        monster_hp_list.pop()
        K -= 1
    else:
        break
print(sum(monster_hp_list))
N, K = map(int,input().split())
H = list(map(int, input().split()))

H_sorted = sorted(H, reverse=True)

print(sum(H_sorted[K:]))

#print(H_sorted)