n=int(input()) for i in range(n): n,k,m=map(int,input().split()) ls=list(map(int,input().split())) ls.sort() total=0 for j in range(k): total+=ls[j] if total>=n: print(total-n) else: print(0)