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

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

a.sort()

mod = 10**9+7



fac = [i for i in range(N + 1)]

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

    fac[i] *= fac[i - 1]

    fac[i] %= mod

fac[0] = 1



fk = pow(fac[K - 1], mod-2, mod)



ans = 0

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

    f = a[-(i + 1)] - a[i]

    nCr = fac[N - i - 1]*pow(fac[N-K-i], mod-2, mod)*fk % mod

    ans += f * nCr

    ans %= mod



print((ans % mod))

class Combination:

    """

    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う

    使い方:

    comb = Combination(SIZE, MOD)

    comb(10, 3) => 120

    """



    def __init__(self, N, MOD=10 ** 9 + 7):

        self.MOD = MOD

        self.fact, self.inv = self._make_factorial_list(N)



    def __call__(self, n, k):

        if k < 0 or k > n or n <= 0:

            return 0

        res = self.fact[n] * self.inv[k] % self.MOD

        res = res * self.inv[n - k] % self.MOD

        return res



    def _make_factorial_list(self, N):

        fact = [1] * (N + 1)

        inv = [1] * (N + 1)

        MOD = self.MOD

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

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

        inv[N] = pow(fact[N], MOD - 2, MOD)

        for i in range(N, 0, -1):

            inv[i - 1] = (inv[i] * i) % MOD

        return fact, inv





if __name__ == "__main__":

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

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

    mod = 10 ** 9 + 7

    comb = Combination(N, mod)



    ans = 0

    A.sort()

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

        Amax = A[-i - 1]

        Amin = A[i]

        ans += (Amax - Amin) * comb(N - i - 1, K - 1)

        ans %= mod



    print(ans)

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
mod = 10**9 + 7
fac = [i for i in range(N + 1)]
for i in range(2, N + 1):
    fac[i] *= fac[i - 1]
    fac[i] %= mod
fac[0] = 1
fk = pow(fac[K - 1], mod - 2, mod)
ans = 0
for i in range(N - K + 1):
    f = a[-(i + 1)] - a[i]
    nCr = fac[N - i - 1] * pow(fac[N - K - i], mod - 2, mod) * fk % mod
    ans += f * nCr
    ans %= mod
print((ans % mod))

class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10**9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n or n <= 0:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    comb = Combination(N, mod)
    ans = 0
    A.sort()
    for i in range(N - K + 1):
        Amax = A[-i - 1]
        Amin = A[i]
        ans += (Amax - Amin) * comb(N - i - 1, K - 1)
        ans %= mod
    print(ans)

-N, K = list(map(int, input().split())) -a = list(map(int, input().split())) -a.sort() -mod = 10**9 + 7 -fac = [i for i in range(N + 1)] -for i in range(2, N + 1): -    fac[i] *= fac[i - 1] -    fac[i] %= mod -fac[0] = 1 -fk = pow(fac[K - 1], mod - 2, mod) -ans = 0 -for i in range(N - K + 1): -    f = a[-(i + 1)] - a[i] -    nCr = fac[N - i - 1] * pow(fac[N - K - i], mod - 2, mod) * fk % mod -    ans += f * nCr -    ans %= mod -print((ans % mod)) +class Combination: +    """ +    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う +    使い方: +    comb = Combination(SIZE, MOD) +    comb(10, 3) => 120 +    """ + +    def __init__(self, N, MOD=10**9 + 7): +        self.MOD = MOD +        self.fact, self.inv = self._make_factorial_list(N) + +    def __call__(self, n, k): +        if k < 0 or k > n or n <= 0: +            return 0 +        res = self.fact[n] * self.inv[k] % self.MOD +        res = res * self.inv[n - k] % self.MOD +        return res + +    def _make_factorial_list(self, N): +        fact = [1] * (N + 1) +        inv = [1] * (N + 1) +        MOD = self.MOD +        for i in range(1, N + 1): +            fact[i] = (fact[i - 1] * i) % MOD +        inv[N] = pow(fact[N], MOD - 2, MOD) +        for i in range(N, 0, -1): +            inv[i - 1] = (inv[i] * i) % MOD +        return fact, inv + + +if __name__ == "__main__": +    N, K = list(map(int, input().split())) +    A = list(map(int, input().split())) +    mod = 10**9 + 7 +    comb = Combination(N, mod) +    ans = 0 +    A.sort() +    for i in range(N - K + 1): +        Amax = A[-i - 1] +        Amin = A[i] +        ans += (Amax - Amin) * comb(N - i - 1, K - 1) +        ans %= mod +    print(ans)