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