import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees

from itertools import permutations, combinations, product, accumulate

# とけてない

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from fractions import gcd

from bisect import bisect

import heapq



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

def INT(): return int(eval(input()))

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

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

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7



N, K = MAP()

A = LIST()



upper = 10**6  # 必要そうな階乗の限界を入れる

factorial = [1]

for i in range(1, upper):

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

def power(x, y):

    if y == 0:

        return 1

    elif y == 1:

        return x % mod

    elif y % 2 == 0:

        return power(x, int(y/2)) ** 2 % mod

    else:

        return power(x, int((y-1)/2)) ** 2 * x % mod



def C(n, r):

    return (((factorial[n] * x_inv[r]) % mod) * x_inv[n-r]) % mod



x_inv = [0] * upper

x_inv[-1] = power(factorial[-1], mod-2)

for i in range(upper-2, -1, -1):

    x_inv[i] = x_inv[i+1] * (i+1) % mod



A.sort()

ma = 0

mi = 0

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

	ma = (ma + A[-i-1] * C(N-1-i, K-1))

	# print("ma:", A[-i-1], "*", C(N-1-i, K-1))

	mi = (mi + A[i] * C(N-1-i, K-1))

	# print("mi", A[i], "*", C(N-1-i, K-1))



# print(ma, mi)

print(((ma-mi)%mod))



import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import accumulate, permutations, combinations, product

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from bisect import bisect, bisect_left

from fractions import gcd

from heapq import heappush, heappop

from functools import reduce

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

def INT(): return int(eval(input()))

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

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

def ZIP(n): return list(zip(*(MAP() for _ in range(n))))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7



N, K = MAP()

A = LIST()

A.sort(reverse=True)

ans = 0



lim = 10**6  # 必要そうな階乗の限界を入れる

fact = [1] * (lim+1)

fact_inv = [1] * (lim+1)

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

    fact[n] = (fact[n-1] * n) % mod

fact_inv[lim] = pow(fact[lim], mod-2, mod)

for n in range(lim, 0, -1):

    fact_inv[n-1] = (n * fact_inv[n]) % mod

def C(n, r):

    return (((fact[n] * fact_inv[r]) % mod) * fact_inv[n-r]) % mod



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

	ans += A[i] * C(N-i-1, K-1)

	ans %= mod

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

	ans -= A[N-i-1] * C(N-i-1, K-1)

	ans %= mod



print(ans)

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate

# とけてない
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
import heapq


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


def INT():
    return int(eval(input()))


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


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


sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N, K = MAP()
A = LIST()
upper = 10**6  # 必要そうな階乗の限界を入れる
factorial = [1]
for i in range(1, upper):
    factorial.append(factorial[i - 1] * i % mod)


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, int(y / 2)) ** 2 % mod
    else:
        return power(x, int((y - 1) / 2)) ** 2 * x % mod


def C(n, r):
    return (((factorial[n] * x_inv[r]) % mod) * x_inv[n - r]) % mod


x_inv = [0] * upper
x_inv[-1] = power(factorial[-1], mod - 2)
for i in range(upper - 2, -1, -1):
    x_inv[i] = x_inv[i + 1] * (i + 1) % mod
A.sort()
ma = 0
mi = 0
for i in range(N - K + 1):
    ma = ma + A[-i - 1] * C(N - 1 - i, K - 1)
    # print("ma:", A[-i-1], "*", C(N-1-i, K-1))
    mi = mi + A[i] * C(N - 1 - i, K - 1)
    # print("mi", A[i], "*", C(N-1-i, K-1))
# print(ma, mi)
print(((ma - mi) % mod))

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


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


def INT():
    return int(eval(input()))


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


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


def ZIP(n):
    return list(zip(*(MAP() for _ in range(n))))


sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N, K = MAP()
A = LIST()
A.sort(reverse=True)
ans = 0
lim = 10**6  # 必要そうな階乗の限界を入れる
fact = [1] * (lim + 1)
fact_inv = [1] * (lim + 1)
for n in range(1, lim + 1):
    fact[n] = (fact[n - 1] * n) % mod
fact_inv[lim] = pow(fact[lim], mod - 2, mod)
for n in range(lim, 0, -1):
    fact_inv[n - 1] = (n * fact_inv[n]) % mod


def C(n, r):
    return (((fact[n] * fact_inv[r]) % mod) * fact_inv[n - r]) % mod


for i in range(N - K + 1):
    ans += A[i] * C(N - i - 1, K - 1)
    ans %= mod
for i in range(N - K + 1):
    ans -= A[N - i - 1] * C(N - i - 1, K - 1)
    ans %= mod
print(ans)

-from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees -from itertools import permutations, combinations, product, accumulate - -# とけてない +from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians +from itertools import accumulate, permutations, combinations, product +from bisect import bisect, bisect_left -from bisect import bisect -import heapq +from heapq import heappush, heappop +from functools import reduce +def ZIP(n): +    return list(zip(*(MAP() for _ in range(n)))) + + -upper = 10**6  # 必要そうな階乗の限界を入れる -factorial = [1] -for i in range(1, upper): -    factorial.append(factorial[i - 1] * i % mod) - - -def power(x, y): -    if y == 0: -        return 1 -    elif y == 1: -        return x % mod -    elif y % 2 == 0: -        return power(x, int(y / 2)) ** 2 % mod -    else: -        return power(x, int((y - 1) / 2)) ** 2 * x % mod +A.sort(reverse=True) +ans = 0 +lim = 10**6  # 必要そうな階乗の限界を入れる +fact = [1] * (lim + 1) +fact_inv = [1] * (lim + 1) +for n in range(1, lim + 1): +    fact[n] = (fact[n - 1] * n) % mod +fact_inv[lim] = pow(fact[lim], mod - 2, mod) +for n in range(lim, 0, -1): +    fact_inv[n - 1] = (n * fact_inv[n]) % mod -    return (((factorial[n] * x_inv[r]) % mod) * x_inv[n - r]) % mod +    return (((fact[n] * fact_inv[r]) % mod) * fact_inv[n - r]) % mod -x_inv = [0] * upper -x_inv[-1] = power(factorial[-1], mod - 2) -for i in range(upper - 2, -1, -1): -    x_inv[i] = x_inv[i + 1] * (i + 1) % mod -A.sort() -ma = 0 -mi = 0 -    ma = ma + A[-i - 1] * C(N - 1 - i, K - 1) -    # print("ma:", A[-i-1], "*", C(N-1-i, K-1)) -    mi = mi + A[i] * C(N - 1 - i, K - 1) -    # print("mi", A[i], "*", C(N-1-i, K-1)) -# print(ma, mi) -print(((ma - mi) % mod)) +    ans += A[i] * C(N - i - 1, K - 1) +    ans %= mod +for i in range(N - K + 1): +    ans -= A[N - i - 1] * C(N - i - 1, K - 1) +    ans %= mod +print(ans)