# import itertools

# import math



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

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

A = sorted(A)



mod = 10**9+7



# print(list(itertools.combinations(range(6), 3)))

# A = range(6)

# N = 6

# K = 3



# 二項係数を素数で割った余り

def combMod(n, r, p):

    if (r < 0) or (n < r):

        return 0

    r = min(r, n - r)

    return fact[n] * factinv[r] * factinv[n-r] % p

fact = [-1 for _ in range(N+1)]

fact[0] = 1

fact[1] = 1

inv = [-1 for _ in range(N+1)]

inv[0] = 0

inv[1] = 1

factinv = [-1 for _ in range(N+1)]

factinv[0] = 1

factinv[1] = 1

# fact = [1, 1]

# factinv = [1, 1]

# inv = [0, 1]

p = mod

    

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

    fact[i] = ((fact[i-1] * i) % p)

    inv[i] = ((-inv[p % i] * (p // i)) % p)

    factinv[i] = ((factinv[i-1] * inv[i]) % p)

    # fact.append((fact[-1] * i) % p)

    # inv.append((-inv[p % i] * (p // i)) % p)

    # factinv.append((factinv[-1] * inv[-1]) % p)









ans = 0

for i in range(N):

    num = combMod(i, K-1, mod) % mod

    ans += num * A[i] % mod

    ans -= num * A[N-i-1] % mod

    ans %= mod



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

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

A = sorted(A)

mod = 10**9+7



# conbModに使うfactとfactinvを求める

def factorialMod(n, p):

    fact = [1, 1]

    factinv = [1, 1]

    inv = [0, 1]

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

        fact.append((fact[-1] * i) % mod)

        inv.append((-inv[mod % i] * (mod // i)) % mod)

        factinv.append((factinv[-1] * inv[-1]) % mod)

    return fact, factinv



# 二項係数を素数で割った余り

def combMod(n, r, fact, factinv, p):

    if (r < 0) or (n < r):

        return 0

    r = min(r, n - r)

    return fact[n] * factinv[r] * factinv[n-r] % p



ans = 0

fact, factinv = factorialMod(N, mod)

for i in range(N):

    num = combMod(i, K-1, fact, factinv, mod) % mod

    ans += num * A[i] % mod

    ans -= num * A[N-i-1] % mod

    ans %= mod



print(ans)
# import itertools
# import math
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
mod = 10**9 + 7
# print(list(itertools.combinations(range(6), 3)))
# A = range(6)
# N = 6
# K = 3
# 二項係数を素数で割った余り
def combMod(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


fact = [-1 for _ in range(N + 1)]
fact[0] = 1
fact[1] = 1
inv = [-1 for _ in range(N + 1)]
inv[0] = 0
inv[1] = 1
factinv = [-1 for _ in range(N + 1)]
factinv[0] = 1
factinv[1] = 1
# fact = [1, 1]
# factinv = [1, 1]
# inv = [0, 1]
p = mod
for i in range(2, N + 1):
    fact[i] = (fact[i - 1] * i) % p
    inv[i] = (-inv[p % i] * (p // i)) % p
    factinv[i] = (factinv[i - 1] * inv[i]) % p
    # fact.append((fact[-1] * i) % p)
    # inv.append((-inv[p % i] * (p // i)) % p)
    # factinv.append((factinv[-1] * inv[-1]) % p)
ans = 0
for i in range(N):
    num = combMod(i, K - 1, mod) % mod
    ans += num * A[i] % mod
    ans -= num * A[N - i - 1] % mod
    ans %= mod
print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
mod = 10**9 + 7
# conbModに使うfactとfactinvを求める
def factorialMod(n, p):
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
    return fact, factinv


# 二項係数を素数で割った余り
def combMod(n, r, fact, factinv, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


ans = 0
fact, factinv = factorialMod(N, mod)
for i in range(N):
    num = combMod(i, K - 1, fact, factinv, mod) % mod
    ans += num * A[i] % mod
    ans -= num * A[N - i - 1] % mod
    ans %= mod
print(ans)

-# import itertools -# import math -# print(list(itertools.combinations(range(6), 3))) -# A = range(6) -# N = 6 -# K = 3 +# conbModに使うfactとfactinvを求める +def factorialMod(n, p): +    fact = [1, 1] +    factinv = [1, 1] +    inv = [0, 1] +    for i in range(2, N + 1): +        fact.append((fact[-1] * i) % mod) +        inv.append((-inv[mod % i] * (mod // i)) % mod) +        factinv.append((factinv[-1] * inv[-1]) % mod) +    return fact, factinv + + -def combMod(n, r, p): +def combMod(n, r, fact, factinv, p): -fact = [-1 for _ in range(N + 1)] -fact[0] = 1 -fact[1] = 1 -inv = [-1 for _ in range(N + 1)] -inv[0] = 0 -inv[1] = 1 -factinv = [-1 for _ in range(N + 1)] -factinv[0] = 1 -factinv[1] = 1 -# fact = [1, 1] -# factinv = [1, 1] -# inv = [0, 1] -p = mod -for i in range(2, N + 1): -    fact[i] = (fact[i - 1] * i) % p -    inv[i] = (-inv[p % i] * (p // i)) % p -    factinv[i] = (factinv[i - 1] * inv[i]) % p -    # fact.append((fact[-1] * i) % p) -    # inv.append((-inv[p % i] * (p // i)) % p) -    # factinv.append((factinv[-1] * inv[-1]) % p) +fact, factinv = factorialMod(N, mod) -    num = combMod(i, K - 1, mod) % mod +    num = combMod(i, K - 1, fact, factinv, mod) % mod