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