ncase = int(raw_input())
for t in range(ncase):
n,k,m = map(int, raw_input().strip().split());
a = map(int, raw_input().split());
a.sort(reverse=False)
sum = 0
for i in range(0,k):
sum += a[i]
if sum - n >= 0:
print sum - n
else:
print 0