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