'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

xFac = [1] * 100001
xFacInv = [1] * 100001
mod = 1000000007

def nCr(n,r):
	return (((xFac[n] * xFacInv[r]) % mod) * xFacInv[n-r]) % mod

def xFacMod():
	for i in range(1, len(xFac)):
		xFac[i] = ( xFac[i-1] * i ) % mod

def powMod(a, b):
	res = 1 
	while b:
		if b % 2: 
			res, b = (res * a) % mod, b-1
		b, a = (b/2), (a*a) % mod
	return res
	
def xFacInvMod():
	xFacInv[100000] = powMod(xFac[100000], mod-2)
	for i in range(99999, 0, -1):
		xFacInv[i] = ((i+1) * xFacInv[i+1]) % mod

def init():
	xFacMod()
	xFacInvMod()

init()
for _ in range(input()):
	n,k = map(int, raw_input().split())
	arr = map(int, raw_input().split())
	arr.sort()
	#print arr
	ans = 0
	for i in range(n-k+1):
		ans = (ans + arr[i] * nCr(n-i-1, k-1)) % mod
	print ans