#[大きい数のnCkの計算]
#https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
def combi(n, k)
  @fac[n] * (@finv[k] * @finv[n - k] % MOD) % MOD
end

MAX = 10 ** 5
MOD = 10 ** 9 + 7
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort

@fac = []
@finv = []
@inv = []
@fac[0] = @fac[1] = 1
@finv[0] = @finv[1] = 1
@inv[1] = 1
2.upto(MAX) do |i|  
  @fac[i] = @fac[i - 1] * i % MOD
  @inv[i] = MOD - @inv[MOD % i] * (MOD / i) % MOD
  @finv[i] = @finv[i - 1] * @inv[i] % MOD
end

res = 0
(N-1).downto(K-1) do |i|
  num = combi(i, K-1)
  res -= (A[N-1-i] * num) % MOD
  res += (A[i] * num) % MOD
end
p res % MOD