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