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]) print( 0 if n >= need_money else need_money-n)