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