N,K = list(map(int,input().split()))

A = list(map(int,input().split()))

A = sorted(A)



mod = 10**9+7





def p(m,n):

    a = 1

    for i in range(n):

        a = a*(m-i)

    return a



def p_mod(m,n,mod):

    a = 1

    for i in range(n):

        a = a*(m-i) % mod

    return a



def c(m,n):

    return p(m,n) // p(n,n)



def c_mod(m,n,mod):

    return (p_mod(m,n,mod)*pow(p_mod(n,n,mod),mod-2,mod)) % mod



C = [0]*(N-K+1)  #C[i] = (N-i-1)C_(K-1),予め二項係数を計算しておく

for i in range(N-K+1):

    if i == 0:

        C[i] = c_mod(N-1,K-1,mod)

    else:

        C[i] = (C[i-1]*(N-K-i+1)*pow(N-i,mod-2,mod)) % mod



#各Aの元が何回max,minに採用されるかを考える



ans = 0

for i in range(N-K+1):

    ans -= (A[i]*C[i]) % mod



A.reverse()

for i in range(N-K+1):

    ans += (A[i]*C[i]) % mod



print((ans % mod))
import sys

def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり



N,K = MI()

A = [-10**10] + LI()

A.sort()



mod = 10**9+7



B = [0]*(K-1) + [1]  # B[i] = i_C_(K-1)

for i in range(K,N):

    B.append((B[-1]*i*pow(i-(K-1),mod-2,mod)) % mod)



ans = 0

for i in range(1,N+1):

    ans += (B[i-1]-B[N-i])*A[i]

    ans %= mod

print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
mod = 10**9 + 7


def p(m, n):
    a = 1
    for i in range(n):
        a = a * (m - i)
    return a


def p_mod(m, n, mod):
    a = 1
    for i in range(n):
        a = a * (m - i) % mod
    return a


def c(m, n):
    return p(m, n) // p(n, n)


def c_mod(m, n, mod):
    return (p_mod(m, n, mod) * pow(p_mod(n, n, mod), mod - 2, mod)) % mod


C = [0] * (N - K + 1)  # C[i] = (N-i-1)C_(K-1),予め二項係数を計算しておく
for i in range(N - K + 1):
    if i == 0:
        C[i] = c_mod(N - 1, K - 1, mod)
    else:
        C[i] = (C[i - 1] * (N - K - i + 1) * pow(N - i, mod - 2, mod)) % mod
# 各Aの元が何回max,minに採用されるかを考える
ans = 0
for i in range(N - K + 1):
    ans -= (A[i] * C[i]) % mod
A.reverse()
for i in range(N - K + 1):
    ans += (A[i] * C[i]) % mod
print((ans % mod))

import sys


def MI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり


N, K = MI()
A = [-(10**10)] + LI()
A.sort()
mod = 10**9 + 7
B = [0] * (K - 1) + [1]  # B[i] = i_C_(K-1)
for i in range(K, N):
    B.append((B[-1] * i * pow(i - (K - 1), mod - 2, mod)) % mod)
ans = 0
for i in range(1, N + 1):
    ans += (B[i - 1] - B[N - i]) * A[i]
    ans %= mod
print(ans)

-N, K = list(map(int, input().split())) -A = list(map(int, input().split())) -A = sorted(A) -mod = 10**9 + 7 +import sys -def p(m, n): -    a = 1 -    for i in range(n): -        a = a * (m - i) -    return a +def MI(): +    return list(map(int, sys.stdin.readline().rstrip().split())) -def p_mod(m, n, mod): -    a = 1 -    for i in range(n): -        a = a * (m - i) % mod -    return a +def LI(): +    return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり -def c(m, n): -    return p(m, n) // p(n, n) - - -def c_mod(m, n, mod): -    return (p_mod(m, n, mod) * pow(p_mod(n, n, mod), mod - 2, mod)) % mod - - -C = [0] * (N - K + 1)  # C[i] = (N-i-1)C_(K-1),予め二項係数を計算しておく -for i in range(N - K + 1): -    if i == 0: -        C[i] = c_mod(N - 1, K - 1, mod) -    else: -        C[i] = (C[i - 1] * (N - K - i + 1) * pow(N - i, mod - 2, mod)) % mod -# 各Aの元が何回max,minに採用されるかを考える +N, K = MI() +A = [-(10**10)] + LI() +A.sort() +mod = 10**9 + 7 +B = [0] * (K - 1) + [1]  # B[i] = i_C_(K-1) +for i in range(K, N): +    B.append((B[-1] * i * pow(i - (K - 1), mod - 2, mod)) % mod) -for i in range(N - K + 1): -    ans -= (A[i] * C[i]) % mod -A.reverse() -for i in range(N - K + 1): -    ans += (A[i] * C[i]) % mod -print((ans % mod)) +for i in range(1, N + 1): +    ans += (B[i - 1] - B[N - i]) * A[i] +    ans %= mod +print(ans)