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