t=int(raw_input()) while t>0: n,k,m=map(int,raw_input().strip().split()) jk=map(int,raw_input().strip().split()) jk.sort() s=0 for i in range(k): s+=jk[i] if s>n: print (s-n) else: print 0 t-=1