Start: Apr, 17, 2017 10:00:00
Python程序设计基础培训第四次作业
End: Apr, 23, 2017 14:00:00
Time elapsed:
Time remaining:

Problem_ID: A
Result: Accepted
Time: 622ms
Memory: 21432kB
Author: 13116772777
In contest: 1088

t=int(raw_input())
for case in range(t): 
	n,k,m = map(int, raw_input().strip().split())
	jg = map(int, raw_input().split())
	jg.sort()

	sum = 0
	for i in range(k):
		sum += jg[i]
	if (sum - n) > 0:
		print sum - n
	else:
		print 0