def mod_inverse(n, mod=10**9+7):

    return pow(n, mod-2, mod)

    



mod = 10**9+7

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

A = [0] + sorted(list(map(int, input().split())))

factorial = [1] * (N+1)

factorial_inv = [1] * (N+1)

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

    factorial[i] = factorial[i-1] * i % mod

    factorial_inv[i] = mod_inverse(factorial[i], mod)



ans = 0

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

    ans = (ans + factorial[i-1] * factorial_inv[i-K] * A[i]) % mod



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

    ans = (ans - factorial[N-i] * factorial_inv[N-K-i+1] * A[i]) % mod



ans = ans * factorial_inv[K-1] % mod

print(ans)

import sys

input = sys.stdin.readline



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

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

mod = 10**9 + 7



fact = [1] * (N+1)

fact_inv = [1] * (N+1)

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

    fact[i] = i * fact[i-1] % mod

fact_inv[N] = pow(fact[N], mod-2, mod)

for i in range(1, N+1)[::-1]:

    fact_inv[i-1] = i * fact_inv[i] % mod

combination = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n-k] % mod



A.sort()

ans = 0

for i in range(N):

    if i >= K - 1:

        ans += A[i] * combination(i, K - 1)

    if N - i - 1 >= K - 1:

        ans -= A[i] * combination(N - i - 1, K - 1)

    ans %= mod

print(ans)
def mod_inverse(n, mod=10**9 + 7):
    return pow(n, mod - 2, mod)


mod = 10**9 + 7
N, K = list(map(int, input().split()))
A = [0] + sorted(list(map(int, input().split())))
factorial = [1] * (N + 1)
factorial_inv = [1] * (N + 1)
for i in range(1, N + 1):
    factorial[i] = factorial[i - 1] * i % mod
    factorial_inv[i] = mod_inverse(factorial[i], mod)
ans = 0
for i in range(K, N + 1):
    ans = (ans + factorial[i - 1] * factorial_inv[i - K] * A[i]) % mod
for i in range(1, N - K + 2):
    ans = (ans - factorial[N - i] * factorial_inv[N - K - i + 1] * A[i]) % mod
ans = ans * factorial_inv[K - 1] % mod
print(ans)

import sys

input = sys.stdin.readline
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 10**9 + 7
fact = [1] * (N + 1)
fact_inv = [1] * (N + 1)
for i in range(1, N + 1):
    fact[i] = i * fact[i - 1] % mod
fact_inv[N] = pow(fact[N], mod - 2, mod)
for i in range(1, N + 1)[::-1]:
    fact_inv[i - 1] = i * fact_inv[i] % mod
combination = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n - k] % mod
A.sort()
ans = 0
for i in range(N):
    if i >= K - 1:
        ans += A[i] * combination(i, K - 1)
    if N - i - 1 >= K - 1:
        ans -= A[i] * combination(N - i - 1, K - 1)
    ans %= mod
print(ans)

-def mod_inverse(n, mod=10**9 + 7): -    return pow(n, mod - 2, mod) +import sys - +input = sys.stdin.readline +N, K = list(map(int, input().split())) +A = list(map(int, input().split())) -N, K = list(map(int, input().split())) -A = [0] + sorted(list(map(int, input().split()))) -factorial = [1] * (N + 1) -factorial_inv = [1] * (N + 1) +fact = [1] * (N + 1) +fact_inv = [1] * (N + 1) -    factorial[i] = factorial[i - 1] * i % mod -    factorial_inv[i] = mod_inverse(factorial[i], mod) +    fact[i] = i * fact[i - 1] % mod +fact_inv[N] = pow(fact[N], mod - 2, mod) +for i in range(1, N + 1)[::-1]: +    fact_inv[i - 1] = i * fact_inv[i] % mod +combination = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n - k] % mod +A.sort() -for i in range(K, N + 1): -    ans = (ans + factorial[i - 1] * factorial_inv[i - K] * A[i]) % mod -for i in range(1, N - K + 2): -    ans = (ans - factorial[N - i] * factorial_inv[N - K - i + 1] * A[i]) % mod -ans = ans * factorial_inv[K - 1] % mod +for i in range(N): +    if i >= K - 1: +        ans += A[i] * combination(i, K - 1) +    if N - i - 1 >= K - 1: +        ans -= A[i] * combination(N - i - 1, K - 1) +    ans %= mod