import sys

def input(): return sys.stdin.readline().strip()

def mapint(): return list(map(int, input().split()))

sys.setrecursionlimit(10**9)



N, K = mapint()

from collections import Counter

As = list(mapint())

count = Counter(As)

mod = 10**9+7

maxi = 0

cum = 0

pos = {}

neg = {}

pos[0] = 1

neg[0] = 1

As = sorted(list(set(As)))

for i in range(1, 10**5+5):

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

    neg[i] = pow(pos[i], mod-2, mod)

for a in As:

    cum += count[a]

    if cum<K:

        continue

    for i in range(1, min(K, count[a])+1):

        if cum-count[a]-K+i<0: continue

        maxi += a*pos[count[a]]*neg[i]*neg[count[a]-i]*pos[cum-count[a]]*neg[K-i]*neg[cum-count[a]-K+i]

        maxi %= mod

mini = 0

cum = 0

for a in As[::-1]:

    cum += count[a]

    if cum<K:

        continue

    for i in range(1, min(K, count[a])+1):

        if cum-count[a]-K+i<0: continue

        mini += a*pos[count[a]]*neg[i]*neg[count[a]-i]*pos[cum-count[a]]*neg[K-i]*neg[cum-count[a]-K+i]

        mini %= mod

print(((maxi-mini)%mod))
import sys

def input(): return sys.stdin.readline().strip()

def mapint(): return list(map(int, input().split()))

sys.setrecursionlimit(10**9)



N, K = mapint()

As = list(mapint())

mod = 10**9+7

As.sort()



pos = {}

neg = {}

pos[0] = 1

neg[0] = 1

for i in range(1, 10**5+3):

    pos[i] = (pos[i-1]*i)%mod

    neg[i] = pow(pos[i], mod-2, mod)



mini = 0

maxi = 0

for i, a in enumerate(As):

    if i<=N-K:

        mini += a*pos[(N-i-1)]*neg[K-1]*neg[N-i-K]

        mini %= mod

    if i>=K-1:

        maxi += a*pos[i]*neg[K-1]*neg[i-K+1]

        maxi %= mod

print(((maxi-mini)%mod))
import sys


def input():
    return sys.stdin.readline().strip()


def mapint():
    return list(map(int, input().split()))


sys.setrecursionlimit(10**9)
N, K = mapint()
from collections import Counter

As = list(mapint())
count = Counter(As)
mod = 10**9 + 7
maxi = 0
cum = 0
pos = {}
neg = {}
pos[0] = 1
neg[0] = 1
As = sorted(list(set(As)))
for i in range(1, 10**5 + 5):
    pos[i] = pos[i - 1] * i % mod
    neg[i] = pow(pos[i], mod - 2, mod)
for a in As:
    cum += count[a]
    if cum < K:
        continue
    for i in range(1, min(K, count[a]) + 1):
        if cum - count[a] - K + i < 0:
            continue
        maxi += (
            a
            * pos[count[a]]
            * neg[i]
            * neg[count[a] - i]
            * pos[cum - count[a]]
            * neg[K - i]
            * neg[cum - count[a] - K + i]
        )
        maxi %= mod
mini = 0
cum = 0
for a in As[::-1]:
    cum += count[a]
    if cum < K:
        continue
    for i in range(1, min(K, count[a]) + 1):
        if cum - count[a] - K + i < 0:
            continue
        mini += (
            a
            * pos[count[a]]
            * neg[i]
            * neg[count[a] - i]
            * pos[cum - count[a]]
            * neg[K - i]
            * neg[cum - count[a] - K + i]
        )
        mini %= mod
print(((maxi - mini) % mod))

import sys


def input():
    return sys.stdin.readline().strip()


def mapint():
    return list(map(int, input().split()))


sys.setrecursionlimit(10**9)
N, K = mapint()
As = list(mapint())
mod = 10**9 + 7
As.sort()
pos = {}
neg = {}
pos[0] = 1
neg[0] = 1
for i in range(1, 10**5 + 3):
    pos[i] = (pos[i - 1] * i) % mod
    neg[i] = pow(pos[i], mod - 2, mod)
mini = 0
maxi = 0
for i, a in enumerate(As):
    if i <= N - K:
        mini += a * pos[(N - i - 1)] * neg[K - 1] * neg[N - i - K]
        mini %= mod
    if i >= K - 1:
        maxi += a * pos[i] * neg[K - 1] * neg[i - K + 1]
        maxi %= mod
print(((maxi - mini) % mod))

-from collections import Counter - -count = Counter(As) -maxi = 0 -cum = 0 +As.sort() -As = sorted(list(set(As))) -for i in range(1, 10**5 + 5): -    pos[i] = pos[i - 1] * i % mod +for i in range(1, 10**5 + 3): +    pos[i] = (pos[i - 1] * i) % mod -for a in As: -    cum += count[a] -    if cum < K: -        continue -    for i in range(1, min(K, count[a]) + 1): -        if cum - count[a] - K + i < 0: -            continue -        maxi += ( -            a -            * pos[count[a]] -            * neg[i] -            * neg[count[a] - i] -            * pos[cum - count[a]] -            * neg[K - i] -            * neg[cum - count[a] - K + i] -        ) +mini = 0 +maxi = 0 +for i, a in enumerate(As): +    if i <= N - K: +        mini += a * pos[(N - i - 1)] * neg[K - 1] * neg[N - i - K] +        mini %= mod +    if i >= K - 1: +        maxi += a * pos[i] * neg[K - 1] * neg[i - K + 1] -mini = 0 -cum = 0 -for a in As[::-1]: -    cum += count[a] -    if cum < K: -        continue -    for i in range(1, min(K, count[a]) + 1): -        if cum - count[a] - K + i < 0: -            continue -        mini += ( -            a -            * pos[count[a]] -            * neg[i] -            * neg[count[a] - i] -            * pos[cum - count[a]] -            * neg[K - i] -            * neg[cum - count[a] - K + i] -        ) -        mini %= mod