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: 409ms
Memory: 24432kB
Author: eboyhcf
In contest: 1124

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