t=int(input()) a=[] for case in range(t): n,k,m=map(int,input().split()) a=list(map(int,input().split())) a.sort() if sum(a[0:k])-n<=0: print(0) else: print(sum(a[0:k])-n)