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: 750ms
Memory: 21428kB
Author: 13587177532
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