Start: Nov, 12, 2017 10:00:00
2017秋Python程序设计基础培训第四次作业
End: Nov, 19, 2017 12:00:00
Time elapsed:
Time remaining:

Problem_ID: A
Result: Accepted
Time: 377ms
Memory: 24436kB
Author: jszxl
In contest: 1124

t=int(input())
i=1
while True:
  try:
    n,k,m=list(map(int,input().split()))
    a=list(map(int,input().split()))
   # print(a)
    a.sort()
    tot=0
    ans=0
    for i in a:
        tot+=1
        if tot<=k:
            ans+=i
        else:
            break
    ans=ans-n
    if ans>0:
      print(ans)
    else:
      print(0)
    i+=1
  except EOFError:
    break