def cmb(n, r, mod):

  if ( r < 0 or r > n ):

    return 0

  r = min(r, n - r)

  return g1[n] * g2[r] * g2[n - r] % mod

 

MOD = 10 ** 9 + 7 #出力の制限

N = 10 ** 5 * 2 + 1

g1 = [1, 1] # 元テーブル

g2 = [1, 1] #逆元テーブル

inverse = [0, 1] #逆元テーブル計算用テーブル

 

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

  g1.append((g1[-1] * i) % MOD)

  inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)

  g2.append((g2[-1] * inverse[-1]) % MOD)



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

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



A.sort()



answer = 0

for i in range(N):

  if i > N - K:

    break

  answer = (answer + (A[N - i - 1] - A[i]) * cmb(N - 1 - i, K - 1, MOD)) % MOD



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

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

MOD = 10 ** 9 + 7



### Combination Table ###

g1 = [1, 1]      # 元テーブル

g2 = [1, 1]      # 逆元テーブル

inverse = [0, 1] # 逆元テーブル計算用テーブル



def comb(n, r, mod):

  if r < 0 or r > n:

    return 0

  r = min(r, n - r)

  return g1[n] * g2[r] * g2[n - r] % mod



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

  g1.append((g1[-1] * i) % MOD)

  inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)

  g2.append((g2[-1] * inverse[-1]) % MOD)

#########################

  

A.sort()



answer = 0

for i in range(N):

  if i > N - K:

    break

  answer = (answer + (A[N - i - 1] - A[i]) * comb(N - 1 - i, K - 1, MOD)) % MOD



print(answer)

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


MOD = 10**9 + 7  # 出力の制限
N = 10**5 * 2 + 1
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
answer = 0
for i in range(N):
    if i > N - K:
        break
    answer = (answer + (A[N - i - 1] - A[i]) * cmb(N - 1 - i, K - 1, MOD)) % MOD
print(answer)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
### Combination Table ###
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル


def comb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


for i in range(2, N + 1):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)
#########################
A.sort()
answer = 0
for i in range(N):
    if i > N - K:
        break
    answer = (answer + (A[N - i - 1] - A[i]) * comb(N - 1 - i, K - 1, MOD)) % MOD
print(answer)

-def cmb(n, r, mod): +N, K = list(map(int, input().split())) +A = list(map(int, input().split())) +MOD = 10**9 + 7 +### Combination Table ### +g1 = [1, 1]  # 元テーブル +g2 = [1, 1]  # 逆元テーブル +inverse = [0, 1]  # 逆元テーブル計算用テーブル + + +def comb(n, r, mod): -MOD = 10**9 + 7  # 出力の制限 -N = 10**5 * 2 + 1 -g1 = [1, 1]  # 元テーブル -g2 = [1, 1]  # 逆元テーブル -inverse = [0, 1]  # 逆元テーブル計算用テーブル -N, K = list(map(int, input().split())) -A = list(map(int, input().split())) +######################### -    answer = (answer + (A[N - i - 1] - A[i]) * cmb(N - 1 - i, K - 1, MOD)) % MOD +    answer = (answer + (A[N - i - 1] - A[i]) * comb(N - 1 - i, K - 1, MOD)) % MOD