T=int(input()) for i in range(T): n,k,m=map(int,input().split()) jg=list(map(int,input().split())) jg.sort() if sum(jg[:k])-n>0: print(sum(jg[:k])-n) else: print(0)