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