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|
  comb = (1..i).to_a.combination(K-1).size
  data[N-1-i] -= comb
  data[i] += comb
end

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