from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions,pprint

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



class Combination:

    """

    comb = Combination(1000000)

    print(comb(5, 3))  # 10

    """

    def __init__(self, n_max, mod=10**9+7):

        self.mod = mod

        self.modinv = self.make_modinv_list(n_max)

        self.fac, self.facinv = self.make_factorial_list(n_max)



    def __call__(self, n, r):

        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod



    def make_factorial_list(self, n):

        # 階乗のリストと階乗のmod逆元のリストを返す O(n)

        # self.make_modinv_list()が先に実行されている必要がある

        fac = [1]

        facinv = [1]

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

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

            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)

        return fac, facinv



    def make_modinv_list(self, n):

        # 0からnまでのmod逆元のリストを返す O(n)

        modinv = [0] * (n+1)

        modinv[1] = 1

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

            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod

        return modinv

n,k = inpl()

a = sorted(inpl())

res = 0

comb = Combination(10**5+10)

for i in range(n):

    if n-i-1 < k-1: continue

    p = comb(n-i-1,k-1)

    res -= a[i] * p

    res += a[-1-i] * p

    res %= mod

print(res)
from collections import Counter,defaultdict,deque

from heapq import heappop,heappush

from bisect import bisect_left,bisect_right 

import sys,math,itertools,fractions

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



class Combination:

    """

    comb = Combination(1000000)

    print(comb(5, 3))  # 10

    """

    def __init__(self, n_max, mod=10**9+7):

        self.mod = mod

        self.modinv = self.make_modinv_list(n_max)

        self.fac, self.facinv = self.make_factorial_list(n_max)



    def __call__(self, n, r):

        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod



    def make_factorial_list(self, n):

        # 階乗のリストと階乗のmod逆元のリストを返す O(n)

        # self.make_modinv_list()が先に実行されている必要がある

        fac = [1]

        facinv = [1]

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

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

            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)

        return fac, facinv



    def make_modinv_list(self, n):

        # 0からnまでのmod逆元のリストを返す O(n)

        modinv = [0] * (n+1)

        modinv[1] = 1

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

            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod

        return modinv



comb = Combination(100010)

n,k = inpl()

a = inpl()

a.sort()

mx = 0

for i in range(n):

    if n-i-1 < k-1: continue

    tmp = comb(n-i-1,k-1)

    # print(tmp)

    mx += tmp*a[-i-1] - tmp*a[i]

    mx %= mod

print(mx) 
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


class Combination:
    """
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv


n, k = inpl()
a = sorted(inpl())
res = 0
comb = Combination(10**5 + 10)
for i in range(n):
    if n - i - 1 < k - 1:
        continue
    p = comb(n - i - 1, k - 1)
    res -= a[i] * p
    res += a[-1 - i] * p
    res %= mod
print(res)

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


class Combination:
    """
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv


comb = Combination(100010)
n, k = inpl()
a = inpl()
a.sort()
mx = 0
for i in range(n):
    if n - i - 1 < k - 1:
        continue
    tmp = comb(n - i - 1, k - 1)
    # print(tmp)
    mx += tmp * a[-i - 1] - tmp * a[i]
    mx %= mod
print(mx)

-from heapq import heappop, heappush, heapify -import sys, bisect, math, itertools, fractions, pprint +from heapq import heappop, heappush +from bisect import bisect_left, bisect_right +import sys, math, itertools, fractions +comb = Combination(100010) -a = sorted(inpl()) -res = 0 -comb = Combination(10**5 + 10) +a = inpl() +a.sort() +mx = 0 -    p = comb(n - i - 1, k - 1) -    res -= a[i] * p -    res += a[-1 - i] * p -    res %= mod -print(res) +    tmp = comb(n - i - 1, k - 1) +    # print(tmp) +    mx += tmp * a[-i - 1] - tmp * a[i] +    mx %= mod +print(mx)