for t in range(int(input())):
n,k,m = map(int, input().split())
p = list(map(int,input().split()))
p.sort()
total = 0
for i in p[:k]:
total += i
if total == 0 or total < n:
print(0)
else:
total -= n
print(total)