#[combi]https://qiita.com/jkr_2255/items/3c9bc8273da818a39810
def combi(n, k)
  k = n-k if 2*k > n
  return 1 if k == 0
  ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort

data = Array.new(N, 0)
(N-1).downto(K-1) do |i|
  num = combi(i, K-1)
  data[N-1-i] -= num
  data[i] += num
end

res = 0
N.times do |i|
  res += A[i] * data[i]
end
p res % (10**9 + 7)