p = 1000000007



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

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



fac = [0] * (N + 1)

fac[0] = 1

for i in range(N):

    fac[i + 1] = fac[i] * (i + 1) % p





def mcomb(n, k):

    if n == 0 and k == 0:

        return 1

    if n < k or k < 0:

        return 0

    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p





A.sort(reverse=True)

result = 0

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

    result += A[i] * mcomb(N - (i + 1), K - 1)

    result %= p



A.reverse()

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

    result -= A[i] * mcomb(N - (i + 1), K - 1)

    result %= p



# result += p

# result %= p

print(result)

# フェルマーの小定理

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

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



m = 1000000007



fac = [0] * (N + 1)

fac[0] = 1

for i in range(N):

    fac[i + 1] = fac[i] * (i + 1) % m





def mcomb(n, k):

    if n == 0 and k == 0:

        return 1

    if n < k or k < 0:

        return 0

    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m





A.sort(reverse=True)

result = 0

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

    result += A[i] * mcomb(N - (i + 1), K - 1)

    result %= m



A.sort()

t = 0

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

    t += A[i] * mcomb(N - (i + 1), K - 1)

    t %= m



result -= t

result %= m

print(result)

p = 1000000007
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
fac = [0] * (N + 1)
fac[0] = 1
for i in range(N):
    fac[i + 1] = fac[i] * (i + 1) % p


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p


A.sort(reverse=True)
result = 0
for i in range(N - K + 1):
    result += A[i] * mcomb(N - (i + 1), K - 1)
    result %= p
A.reverse()
for i in range(N - K + 1):
    result -= A[i] * mcomb(N - (i + 1), K - 1)
    result %= p
# result += p
# result %= p
print(result)

# フェルマーの小定理
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
m = 1000000007
fac = [0] * (N + 1)
fac[0] = 1
for i in range(N):
    fac[i + 1] = fac[i] * (i + 1) % m


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


A.sort(reverse=True)
result = 0
for i in range(N - K + 1):
    result += A[i] * mcomb(N - (i + 1), K - 1)
    result %= m
A.sort()
t = 0
for i in range(N - K + 1):
    t += A[i] * mcomb(N - (i + 1), K - 1)
    t %= m
result -= t
result %= m
print(result)

-p = 1000000007 +# フェルマーの小定理 +m = 1000000007 -    fac[i + 1] = fac[i] * (i + 1) % p +    fac[i + 1] = fac[i] * (i + 1) % m -    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p +    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m -    result %= p -A.reverse() +    result %= m +A.sort() +t = 0 -    result -= A[i] * mcomb(N - (i + 1), K - 1) -    result %= p -# result += p -# result %= p +    t += A[i] * mcomb(N - (i + 1), K - 1) +    t %= m +result -= t +result %= m