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