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