Start: Jul, 17, 2019 00:00:00
20190717Python程序设计基础培训扩展练习
End: Jul, 21, 2019 00:00:00
Time elapsed:
Time remaining:

Problem_ID: A
Result: Accepted
Time: 312ms
Memory: 25316kB
Author: 13758380235
In contest: 1296

t=int(input())
for tcase in range(t):
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    b.sort()
    s=0
    for i in range(0,a[1]):
        s+=b[i]
    print(s-a[0] if s-a[0]>=0 else 0)