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