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