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

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