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