CodeEff/ECCO huggingface dataset:
# Original solution
n,s = list(map(int, input().split()))
a = list(map(int, input().split()))


dp = [[0] * (s + 1) for _ in range(n+1)]


for i in range(1, n+1):
    for j in range(1, s+1):
        if a[i-1] > j:
            dp[i][j] = dp[i-1][j]
        elif a[i-1] == j:
            dp[i][j] = dp[i-1][j] + i
        else:
            dp[i][j] = dp[i-1][j] + dp[i-1][j-a[i-1]]

ans = 0

for i in range(1, n+1):
    ans += dp[i][s]
    ans %= 998244353


print(ans)

# Optimized solution
n,s = list(map(int, input().split()))
a = list(map(int, input().split()))


dp = [[0] * (s + 1) for _ in range(n+1)]


for i in range(1, n+1):
    for j in range(1, s+1):
        if a[i-1] > j:
            dp[i][j] = dp[i-1][j]
        elif a[i-1] == j:
            dp[i][j] = (dp[i-1][j] + i)%998244353
        else:
            dp[i][j] = (dp[i-1][j] + dp[i-1][j-a[i-1]])%998244353

ans = 0

for i in range(1, n+1):
    ans += dp[i][s]
    ans %= 998244353


print(ans)
# Original solution
# https://atcoder.jp/contests/abc159/submissions/11139734

def main():
    MOD = 998244353

    N, S = list(map(int, input().split()))
    *A, = list(map(int, input().split()))

    ans = 0
    dp = [0] * (S + 1)
    for i, a in enumerate(A, start=1):
        dp[0] = i  # i以前の(i+1)通りの起点がある（以後未取得）
        ans += dp[S]  # aを取らずにclose
        if S >= a:
            ans += dp[S - a]  # aを取ってclose
        ans %= MOD
        for s in reversed(list(range(a, S + 1))):
            dp[s] += dp[s - a]
            dp[s] %= MOD

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    MOD = 998244353

    N, S = list(map(int, input().split()))
    *A, = list(map(int, input().split()))

    dp = [0] * (S + 1)
    ans = 0
    for x in A:
        dp[0] += 1
        for j in range(S, x - 1, -1):
            dp[j] = (dp[j] + dp[j - x]) % MOD
        ans = (ans + dp[S]) % MOD
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 998244353

N, S = MAP()
A = LIST()

# dp0[i][j] := i番目の要素まで見て、総和がjで、使う区間が未確定の状態の通り数
dp0 = list2d(N+1, S+1, 0)
# dp1[i][j] := i番目の要素まで見て、総和がjで、使う区間がL確定済の状態の通り数
dp1 = list2d(N+1, S+1, 0)
# dp2[i][j] := i番目の要素まで見て、総和がjで、使う区間がLR確定済の状態の通り数
dp2 = list2d(N+1, S+1, 0)
dp0[0][0] = 1
for i, a in enumerate(A):
    for j in range(S+1):
        # aを総和に足さない遷移は全部OK
        dp0[i+1][j] += dp0[i][j]
        dp1[i+1][j] += dp0[i][j] + dp1[i][j]
        dp2[i+1][j] += dp0[i][j] + dp1[i][j] + dp2[i][j]
        # aを総和に足す遷移は、遷移元が状態2と遷移先が状態0は無理
        if j+a <= S:
            dp1[i+1][j+a] += dp0[i][j] + dp1[i][j]
            dp2[i+1][j+a] += dp0[i][j] + dp1[i][j]
        dp0[i+1][j] %= MOD
        dp1[i+1][j] %= MOD
        dp2[i+1][j] %= MOD
ans = dp2[N][S]
print(ans)


# Optimized solution
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 998244353

N, S = MAP()
A = LIST()

dp0 = [0] * (S+1)
dp1 = [0] * (S+1)
dp2 = [0] * (S+1)
nxt0 = [0] * (S+1)
nxt1 = [0] * (S+1)
nxt2 = [0] * (S+1)
dp0[0] = 1
for i, a in enumerate(A):
    for j in range(S+1):
        # aを総和に足さない遷移は全部OK
        nxt0[j] += dp0[j]
        nxt1[j] += dp0[j] + dp1[j]
        nxt2[j] += dp0[j] + dp1[j] + dp2[j]
        # aを総和に足す遷移は、遷移元が状態2と遷移先が状態0は無理
        if j+a <= S:
            nxt1[j+a] += dp0[j] + dp1[j]
            nxt2[j+a] += dp0[j] + dp1[j]
        nxt0[j] %= MOD
        nxt1[j] %= MOD
        nxt2[j] %= MOD
    dp0 = nxt0[:]
    dp1 = nxt1[:]
    dp2 = nxt2[:]
    nxt0 = [0] * (S+1)
    nxt1 = [0] * (S+1)
    nxt2 = [0] * (S+1)
ans = dp2[S]
print(ans)
# Original solution
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 998244353
N, S = lr()
A = lr()
dp = [0] * (S+1)
answer = 0
for a in A:
    dp[0] += 1 # Lの数は１個ずつ加わる
    prev = dp.copy()
    for i in range(S-a+1):
        dp[i+a] += prev[i]
    answer += dp[-1] # その位置Rとした時

print((answer % MOD))
# 26

# Optimized solution
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 998244353
N, S = lr()
A = lr()
dp = [0] * (S+1)
answer = 0
for a in A:
    dp[0] += 1 # Lの数は１個ずつ加わる
    prev = dp[:]
    for i in range(S-a+1):
        dp[i+a] += prev[i]
    answer += dp[-1] # その位置をRとした時

print((answer % MOD))
# 26
# Original solution
import sys
MOD = 998244353
def main():
    input = sys.stdin.readline
    N, S = list(map(int, input().split()))
    *A, = list(map(int, input().split()))
    A = [0] + A
    dp = [[[0] * 3 for __ in range(S + 5)] for _ in range(N + 5)]
    dp[0][0][0] = 1
    for i in range(1, N + 1):
        for s in range(S + 1):
            ps = s - A[i]
            # 0->0
            dp[i][s][0] = (dp[i][s][0] + dp[i - 1][s][0]) % MOD

            # 0->1
            dp[i][s][1] = (dp[i][s][1] + dp[i - 1][s][0]) % MOD
            if ps >= 0:
                dp[i][s][1] = (dp[i][s][1] + dp[i - 1][ps][0]) % MOD

            # 1->1
            dp[i][s][1] = (dp[i][s][1] + dp[i - 1][s][1]) % MOD
            if ps >= 0:
                dp[i][s][1] = (dp[i][s][1] + dp[i - 1][ps][1]) % MOD

            # 0->2
            dp[i][s][2] = (dp[i][s][2] + dp[i - 1][s][0]) % MOD
            if ps >= 0:
                dp[i][s][2] = (dp[i][s][2] + dp[i - 1][ps][0]) % MOD

            # 1->2
            dp[i][s][2] = (dp[i][s][2] + dp[i - 1][s][1]) % MOD
            if ps >= 0:
                dp[i][s][2] = (dp[i][s][2] + dp[i - 1][ps][1]) % MOD

            # 2->2
            dp[i][s][2] = (dp[i][s][2] + dp[i - 1][s][2]) % MOD
    print((dp[N][S][2]))

if __name__ == '__main__':
    main()


# Optimized solution
import sys
MOD = 998244353
def main():
    input = sys.stdin.readline
    N, S = list(map(int, input().split()))
    *A, = list(map(int, input().split()))
    A = [0] + A
    dp = [[0] * 3 for __ in range(S + 5)]
    dp[0][0] = 1
    for i in range(1, N + 1):
        for s in range(S, -1, -1):
            ps = s - A[i]
            dp[s][1] = (dp[s][1] + dp[s][0]) % MOD
            dp[s][2] = (dp[s][2] + dp[s][0]) % MOD
            dp[s][2] = (dp[s][2] + dp[s][1]) % MOD
            if ps >= 0:
                dp[s][1] = (dp[s][1] + dp[ps][0]) % MOD
                dp[s][1] = (dp[s][1] + dp[ps][1]) % MOD
                dp[s][2] = (dp[s][2] + dp[ps][0]) % MOD
                dp[s][2] = (dp[s][2] + dp[ps][1]) % MOD

    print((dp[S][2]))

if __name__ == '__main__':
    main()
# Original solution
def setM():
    k = K2 // 2
    while k:
        m = int(("1" * (K2 - k) + "0" * (K2 + k)) * 3001, 2)
        M.append((k, m, ~m, (1 << K2 + k) % P))
        k //= 2
        break

def modp(n):
    for k, m, tm, a in M:
        n = (n & tm) + ((n & m) >> K2 + k) * a
    return n

K = 64
K2 = K // 2
P = 998244353
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
M = []
setM()
N, S = list(map(int, input().split()))
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
    s += 1
    s += s << a * K
    s &= mm
    s = modp(s)
    ans += (s >> S * K) & mmm

print((ans % P))

# Optimized solution
K = 32
P = 998244353
m = int(("1" * 2 + "0" * 30) * 3001, 2)
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
pa = (1 << 30) - ((1 << 30) % P)

M = []
N, S = list(map(int, input().split()))
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
    s += 1
    s += s << a * K
    s &= mm
    s -= ((s & m) >> 30) * pa
    ans += (s >> S * K) & mmm

print((ans % P))
# Original solution
import bisect
n,s = list(map(int,input().split()))
a = list(map(int,input().split()))
mod = 998244353
rui = []
now = 0
pl = []
for i in range(n):
    now += a[i]
    rui.append(now)
l = [[0 for i in range(s)] for i in range(n)]
ans = 0
for i in range(n):
    if a[i] < s:
        l[i][a[i]] += i+1
    elif a[i] == s:
        ans += i*(n-i-1)
        ans += n
        ans %= mod
    for j in range(s):
        if i > 0:
            if l[i-1][j] > 0:
                if j+a[i] < s:
                    l[i][j+a[i]] += l[i-1][j]
                elif j+a[i] == s:
                    ans += l[i-1][j]*(n-i)
                    ans %= mod
                l[i][j] += l[i-1][j]
print(ans)

# Optimized solution
n,s = list(map(int,input().split()))
a = list(map(int,input().split()))
mod = 998244353
rui = []
now = 0
pl = []
for i in range(n):
    now += a[i]
    rui.append(now)
l = [[0 for i in range(s)] for i in range(n)]
ans = 0
for i in range(n):
    if a[i] < s:
        l[i][a[i]] += i+1
        l[i][a[i]] %= mod
    elif a[i] == s:
        ans += i*(n-i-1)
        ans += n
        ans %= mod
    for j in range(s):
        if i > 0:
            if l[i-1][j] > 0:
                if j+a[i] < s:
                    l[i][j+a[i]] += l[i-1][j]
                    l[i][j+a[i]] %= mod
                elif j+a[i] == s:
                    ans += l[i-1][j]*(n-i)
                    ans %= mod
                l[i][j] += l[i-1][j]
                l[i][j] %= mod
print(ans)
# Original solution
N, S = list(map(int, input().split()))
mod = 998244353
A = list(map(int, input().split()))
dp1 = [[0]*(S+1) for _ in range(N+1)]
dp2 = [[0]*(S+1) for _ in range(N+1)]

for i in range(1, N+1):
    a = A[i-1]
    dp1[i][0] = 1
    for j in range(S+1):
        dp1[i][j] += dp1[i-1][j]
        dp2[i][j] = dp2[i-1][j]
        if j == a:
            dp1[i][j] += 1
        if j-a >= 0:
            dp1[i][j] += dp1[i-1][j-a]
        dp2[i][j] += dp1[i][j]
        dp1[i][j] %= mod
        dp2[i][j] %= mod

print((dp2[-1][S]))
#print(dp[1])
#print(dp[2])
#print(dp[3])


# Optimized solution
N, S = list(map(int, input().split()))
mod = 998244353
A = list(map(int, input().split()))
dp1 = [[0]*(S+1) for _ in range(N+1)]
r = 0

for i in range(1, N+1):
    a = A[i-1]
    dp1[i][0] = 1
    for j in range(S+1):
        dp1[i][j] += dp1[i-1][j]
        if j == a:
            dp1[i][j] += 1
        if j-a >= 0:
            dp1[i][j] += dp1[i-1][j-a]
        dp1[i][j] %= mod
    r += dp1[i][S]
print((r%mod))
# Original solution
n, s = list(map(int, input().split()))
A = list(map(int, input().split()))
dp = [[0] * (s + 1) for _ in range(n + 1)]

mod = 998244353
# dp[i][s] A[i]まで見た時、合計sになる数。
# 各々の地点で新しく開始されるものも有るので毎回dp[i][0]は＋1
dp[0][0] = 1
ans = 0
for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
    dp[ni][0] += 1
    ans += dp[ni][s]
    ans %= mod
print(ans)


# Optimized solution
import sys

input = sys.stdin.buffer.readline
n, s = list(map(int, input().split()))
A = list(map(int, input().split()))
dp = [[0] * (s + 1) for _ in range(n + 1)]

mod = 998244353
# dp[i][s] A[i]まで見た時、合計sになる数。
# 各々の地点で新しく開始されるものも有るので毎回dp[i][0]は＋1
dp[0][0] = 1
ans = 0
for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
    dp[ni][0] += 1
    ans += dp[ni][s]
    ans %= mod
print(ans)
# Original solution
import sys

input = sys.stdin.buffer.readline
n, s = list(map(int, input().split()))
A = list(map(int, input().split()))
dp = [[0] * (s + 1) for _ in range(n + 1)]

mod = 998244353
# dp[i][s] A[i]まで見た時、合計sになる数。
# 各々の地点で新しく開始されるものも有るので毎回dp[i][0]は＋1
dp[0][0] = 1
ans = 0
for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
    dp[ni][0] += 1
    ans += dp[ni][s]
    ans %= mod
print(ans)


# Optimized solution
n, s = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s + 1) for _ in range(n + 1)]
for i in range(n):
    dp[i][0] = 1
for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
ans = 0
for i in range(n + 1):
    ans += dp[i][s]
    ans %= mod
print(ans)
# Original solution
val1,val2=input().split(" ")
val3=int(val1)-int(val2)+1
print(val3)

# Optimized solution
def main():
    N, i = list(map(int, input().strip().split()))
    print((N - i + 1))
 
if __name__ == "__main__":
    main()
# Original solution
N,i =input().split()
N =int(N)
i =int(i)
m =(N-i)+1
print(m)

# Optimized solution
m , i = list(map(int, input().split()))

print((m + 1 - i))
# Original solution
n, i = list(map(int, input().split()))
if n == 1:
    print((1))
else:
    print((n - i + 1))

# Optimized solution
n, i = list(map(int, input().split()))
print((n - i + 1))
# Original solution
N,i=list(map(int,input().split( )))
count=0

while N>=i:
    count+=1
    N-=1


print(count)

# Optimized solution
n,i=list(map(int,input().split()))
j=0
for v in range(n):
    j=j+1
    if (n-1)>= i:
        
        n=n-1

    else:    
        break
 
print (j)
# Original solution
n,i=list(map(int,input().split()))
j=0
for v in range(n):
    j=j+1
    if (n-1)>= i:
        
        n=n-1

    else:    
        break
 
print (j)


# Optimized solution
N,i=[int(x)for x in input().split()]
x=N-i+1
print(x)
# Original solution
n,i = list(map(int,input().split()))
x = []
for t in range(n+1):
    x.append(t)
print((x[n-i+1]))

# Optimized solution
n,i = list(map(int,input().split()))
print((n-i+1))
# Original solution
# sys.stdin.readline()
import sys
input = sys.stdin.readline

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

print((n + 1 - i))

# Optimized solution
n , i = list(map(int, input().split()))
print((n + 1 - i))
# Original solution
n,m = list(map(int,input().split()))
print((n-m+1))

# Optimized solution
n ,i = list(map(int,input().split()))
print((n-i+1))
# Original solution
n,i=list(map(int,input().split()))
print((n-i+1))


# Optimized solution
a,b=list(map(int,input().split()))
print((a-b+1))
# Original solution
print((eval(input().replace(" ","-"))+1))

# Optimized solution
n,i = list(map(int,input().split()))
print((1+n-i))
# Original solution
A,B = list(map(int,input().split()))
print((A-B+1))

# Optimized solution
n,i = list(map(int,input().split()))
print((n+1-i))
# Original solution
import sys
rm = lambda: list(map(int, sys.stdin.buffer.readline().split()))

a, b = rm()
print((a+1-b))

# Optimized solution
import sys
rm = lambda: list(map(int, sys.stdin.buffer.readline().split()))

a, b = rm()
print((a-b+1))
# Original solution
print((eval(input().replace(" ","-")+"+1")))

# Optimized solution
print((eval(input().replace(" ","-"))+1))
# Original solution
a, b = list(map(int, input().split(" ")))
print((a - b + 1))

# Optimized solution
N, i = list(map(int, input().split()))
print((N - i + 1))
# Original solution
n,k = list(map(int, input().split()))
h = list(map(int,input().split()))
sort_h = sorted(h, reverse=True)
if len(h) <= k:
  ans = 0
else:
  for i in range(0, k):
    del sort_h[0]
  ans = sum(sort_h)
print(ans)

# Optimized solution
n,k = list(map(int, input().split()))
h = list(map(int,input().split()))
sort_h = sorted(h)
if len(h) <= k:
  ans = 0
else:
  for i in range(0, k):
    sort_h.pop()
  ans = sum(sort_h)
print(ans)
# Original solution

class Solution:
    def solve(self, H, k, monsters):
        monsters.sort(reverse=True)

        i = 0

        while i < k and len(monsters) > 0:
            monsters.pop(0)
            i += 1

        ans = 0

        for monster in monsters:
            ans += monster

        return ans


sol = Solution()

[H, k] = list(map(int, input().strip().split()))
monsters = list(map(int, input().strip().split()))

print((sol.solve(H, k, monsters)))


# Optimized solution

class Solution:
    def solve(self, H, k, monsters):
        monsters.sort(reverse=True)

        return sum(monsters[k:])


sol = Solution()

[H, k] = list(map(int, input().strip().split()))
monsters = list(map(int, input().strip().split()))

print((sol.solve(H, k, monsters)))
# Original solution
n, h = list(map(int, input().split()))
list_score = list(map(int, input().split()))

list_score.sort()

if h >= len(list_score):
    h = len(list_score)

for i in range(h):
    list_score.pop(-1)

ans = sum(list_score)

print(ans)

# Optimized solution
n, h = list(map(int, input().split()))
list_score = list(map(int, input().split()))

list_score.sort()
if h > n:
    print((0))
else:
    ans = sum(list_score[:n-h])
    print(ans)
# Original solution
special_moves = input().split(" ")

_, special_moves = int(special_moves [0]), int(special_moves [1])

health= input().split(" ")
health= [int(h) for h in health]
health.sort(reverse=True)
print((sum(health[special_moves:])))

# Optimized solution
n, k = list (map (int, input ().split ()))
h = sorted (list (map (int, input ().split ())), reverse=True)
h = h[k : ]
print((sum (h)))
# Original solution
nk = list(map(int,input().split()))
n,k = nk
h = list(map(int,input().split()))
if k >= len(h):
    print((0))
else:
    h.sort()
    for i in range (k):
        h.pop()
    print((sum(h)))

# Optimized solution
nMonsters, nSpecial = [int(x) for x in input().split()]

monst = [int(x) for x in input().split()]

monst.sort()

nMonsters -= nSpecial

if nMonsters < 0:
    print((0))
else:
    print((sum(monst[0:nMonsters])))
# Original solution
def fennec_vs_monster():
    # 入力
    N, K = list(map(int, input().split()))
    H = list(map(int, input().split()))
    # 体力リストの大きい順からK個だけ排除
    for i in range(K):
        # 体力リストが空でないときは以下を実行
        if i < N:
            max_H = max(H)
            H.remove(max_H)
    # 残りの体力リストを合計
    sum_H = sum(H)
    # 攻撃の回数の最小値
    return sum_H

result = fennec_vs_monster()
print(result)

# Optimized solution
def fennec_vs_monster():
    # 入力
    N, K = list(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)
# Original solution
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

for i in range(K):
    if len(H)!=0:
        H.remove(max(H))
        #print(H)
    else:
        #print(0)
        break
print((sum(H)))


# Optimized solution
'''N, K = map(int, input().split())
H = list(map(int, input().split()))

for i in range(K):
    if len(H)!=0:
        H.remove(max(H))
        #print(H)
    else:
        #print(0)
        break
print(sum(H))'''

N, K = list(map(int, input().split()))
H = list(map(int, input().split()))
H.sort(reverse=True)

print((sum(H[K:])))
# Original solution
h, k = list(map(int, input().split()))
lis = list(map(int, input().split()))
if len(lis) >= k:
    for i in range(k):
        lis.remove(max(lis))
else:
    lis = []
    
print((sum(lis)))

# Optimized solution
h, k = list(map(int, input().split()))
lis = list(map(int, input().split()))
if h >= k:
    lis.sort(reverse=True)
    lis = lis[k:]
else:
    lis = []
    
print((sum(lis)))
# Original solution
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))
ans = sum(H)
for n in range(1,min(N+1,K+1)):
    ans -= sorted(H)[-n]
print(ans)


# Optimized solution
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

cnt = 0
H.sort(reverse=True)

if K >= N:
    print((0))
else:
    print((sum(H[K:])))
# Original solution
n, k = list(map(int, input().split()))
h = [int(i) for i in input().split()]
h.sort()
nokori = max(0, n - k)
h = h[:nokori]
print((sum(h)))


# Optimized solution
def main():
    n, k = list(map(int, input().split()))
    h = list(map(int, input().split()))

    if n <= k:
        print((0))
    else:
        h.sort(reverse=True)
        print((sum(h[k:])))

if __name__ == '__main__':
    main()
# Original solution
n, k = list(map(int, input().split()))
hl = list(map(int, input().split()))
hl_s = sorted(hl, reverse=True)

if k >= n:
    print((0))
else:
    for _ in range(k):
        hl_s.pop(0)
    print((sum(hl_s)))

# Optimized solution
n, k = list(map(int, input().split()))
hl = list(map(int, input().split()))
hl_s = sorted(hl, reverse=True)

if k >= n:
    print((0))
else:
    del hl_s[0:k]
    print((sum(hl_s)))
# Original solution
#!/user/bin/env python
#pythonプログラムであることを示している

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

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t.sort(reverse=True)
    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    # for j in range(d):  #必殺技の回数
    #     c = sum(t)
    #     if c != 0:
    #         g = max(t)
    #         for i in range(b):
    #             if g == t[i]:
    #                 t[i] = 0
    #                 break
    #         t[f] = 0
    #         f = 0
    #     else:
    #         break
    c = sum(t)
    for i in range(d):
        if c != 0:
            c -= t[i]
            t[i] = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

# Optimized solution
#!/user/bin/env python
#pythonプログラムであることを示している

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

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t.sort(reverse=True)
    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    c = sum(t)
    for i in range(d):
        if c != 0:
            c -= t[i]
            t[i] = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())
# Original solution
N,K = list(map(int, input().split()))
H = list(map(int, input().split()))

H.sort(reverse=True)

if(N<=K):
  print((0))
else:
  for i in range(K):
    H.pop(0)
  print((sum(H)))

# Optimized solution
N,K = list(map(int, input().split()))
H = list(map(int, input().split()))

H.sort()

if(N<=K):
  print((0))
else:
  for i in range(K):
    H.pop()
  print((sum(H)))
# Original solution
import sys
n, k = list(map(int, input().split()))
H = list(map(int, input().split()))

H = sorted(H, reverse=True)
if k >= n:
  print((0))
  sys.exit()
for i in range(k):    
  H.pop(0)
cnt = 0
for h in H:
  cnt += h
print(cnt)


# Optimized solution
import sys
n, k = list(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)
# Original solution
f = lambda:list(map(int,input().split()))
n, k = f()
l = sorted(list(f()))
print((sum(l[:n-k]) if n>k else 0))

# Optimized solution
f = lambda:list(map(int,input().split()))
n, k = f()
l = sorted(list(f()))
k = min(k,n)
print((sum(l[:n-k])))