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

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