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: 690ms
Memory: 21432kB
Author: 13967581231
In contest: 1088

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