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

T=int(raw_input())
for i in range(T):
	n,k,m=map(int,raw_input().strip().split())
	kind=map(int,raw_input().strip().split())
	kind.sort()
	sum=0
	for j in range(k):
		sum+=kind[j]
	if sum-n<=0:
		print "0"
	else:	
		print sum-n