t=int(raw_input()) for case in range(t): n,k,m = map(int, raw_input().strip().split()) list = map(int, raw_input().split()) list.sort() sum = 0 for i in range(k): sum += list[i] if (sum - n) > 0: print sum - n else: print 0