t=int(input()) for j in range(t): n,k,m=map(int,raw_input().strip().split()) mo=map(int,raw_input().strip().split()) mo.sort() x=0 for i in range(k): x+=mo[i] if n<x: print x-n else: print 0