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

t=int(input())
for j in range(t):
	n,k,m=map(int,raw_input().strip().split())
	mo=map(int,raw_input().strip().split())
	mo.sort()
	x=0
	for i in range(k):
		x+=mo[i]
	if n<x:
		print x-n
	else:
		print 0