MOD = 10**9 + 7



class Combination:

    def __init__(self, size):

        self.size = size + 2

        self.fact = [1, 1] + [0] * size

        self.factInv = [1, 1] + [0] * size

        self.inv = [0, 1] + [0] * size



        for i in range(2, self.size):

            self.fact[i] = self.fact[i - 1] * i % MOD

            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD

            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD



    def npr(self, n, r):

        if n < r or n < 0 or r < 0:

            return 0

        return self.fact[n] * self.factInv[n - r] % MOD



    def ncr(self, n, r):

        if n < r or n < 0 or r < 0:

            return 0

        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD



    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r

        return self.ncr(n + r - 1, n - 1)



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

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

MOD = 10**9 + 7

comb = Combination(N + 10)



A.sort()

ans = 0

for i, a in enumerate(A):

    mi = comb.ncr(N - i - 1, K - 1)

    mx = comb.ncr(i, K - 1)

    ans += (mx - mi) * a

    ans %= MOD

print(ans)

MOD = 10**9 + 7



class Combination:

    def __init__(self, size):

        self.size = size + 2

        self.fact = [1, 1] + [0] * size

        self.factInv = [1, 1] + [0] * size

        self.inv = [0, 1] + [0] * size



        for i in range(2, self.size):

            self.fact[i] = self.fact[i - 1] * i % MOD

            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD

            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD



    def npr(self, n, r):

        if n < r or n < 0 or r < 0:

            return 0

        return self.fact[n] * self.factInv[n - r] % MOD



    def ncr(self, n, r):

        if n < r or n < 0 or r < 0:

            return 0

        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD



    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r

        return self.ncr(n + r - 1, n - 1)



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

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

comb = Combination(N + 100)

A.sort()



ans = 0

for i, a in enumerate(A):

    ans += a * comb.ncr(i, K - 1)

    ans -= a * comb.ncr(N - i - 1, K - 1)

    ans %= MOD

print(ans)

MOD = 10**9 + 7


class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size
        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
comb = Combination(N + 10)
A.sort()
ans = 0
for i, a in enumerate(A):
    mi = comb.ncr(N - i - 1, K - 1)
    mx = comb.ncr(i, K - 1)
    ans += (mx - mi) * a
    ans %= MOD
print(ans)

MOD = 10**9 + 7


class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size
        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
comb = Combination(N + 100)
A.sort()
ans = 0
for i, a in enumerate(A):
    ans += a * comb.ncr(i, K - 1)
    ans -= a * comb.ncr(N - i - 1, K - 1)
    ans %= MOD
print(ans)

-MOD = 10**9 + 7 -comb = Combination(N + 10) +comb = Combination(N + 100) -    mi = comb.ncr(N - i - 1, K - 1) -    mx = comb.ncr(i, K - 1) -    ans += (mx - mi) * a +    ans += a * comb.ncr(i, K - 1) +    ans -= a * comb.ncr(N - i - 1, K - 1)