MOD=10**9+7

n,k=list(map(int,input().split()))

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



a.sort(reverse=True)





fact = [1]

fact_inv = [1]

mod=10**9+7

for i in range(10**5+1):

    new_fact = fact[-1]*(i+1)%mod

    fact.append(new_fact)

    fact_inv.append(pow(new_fact,mod-2,mod))





def mod_comb_k(n,k,mod):

    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod



  

c=[]

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

  c.append(mod_comb_k(n-i,k-1,MOD))

lc=len(c)

#print(c,a)

sum=0

for i in range(lc):

  sum+=c[i]*(a[i]-a[-i-1])%MOD

  

print((sum%MOD))

MOD=10**9+7

n,k=list(map(int,input().split()))

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



a.sort(reverse=True)



#前計算

fact = [1]

fact_inv = [1]

mod=10**9+7

for i in range(n+1):

    new_fact = fact[-1]*(i+1)%mod

    fact.append(new_fact)

    fact_inv.append(pow(new_fact,mod-2,mod))



def mod_comb_k(n,k,mod):

    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

#前計算終わり

  

c=[]

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

  c.append(mod_comb_k(n-i,k-1,MOD))

  

lc=len(c)

sum=0

for i in range(lc):

  sum+=c[i]*(a[i]-a[-i-1])%MOD

  

print((sum%MOD))

MOD = 10**9 + 7
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
fact = [1]
fact_inv = [1]
mod = 10**9 + 7
for i in range(10**5 + 1):
    new_fact = fact[-1] * (i + 1) % mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact, mod - 2, mod))


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod


c = []
for i in range(1, n - k + 1 + 1):
    c.append(mod_comb_k(n - i, k - 1, MOD))
lc = len(c)
# print(c,a)
sum = 0
for i in range(lc):
    sum += c[i] * (a[i] - a[-i - 1]) % MOD
print((sum % MOD))

MOD = 10**9 + 7
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
# 前計算
fact = [1]
fact_inv = [1]
mod = 10**9 + 7
for i in range(n + 1):
    new_fact = fact[-1] * (i + 1) % mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact, mod - 2, mod))


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod


# 前計算終わり
c = []
for i in range(1, n - k + 1 + 1):
    c.append(mod_comb_k(n - i, k - 1, MOD))
lc = len(c)
sum = 0
for i in range(lc):
    sum += c[i] * (a[i] - a[-i - 1]) % MOD
print((sum % MOD))

+# 前計算 -for i in range(10**5 + 1): +for i in range(n + 1): +# 前計算終わり -# print(c,a)