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