n, k, *a = $stdin.read.split.map(&:to_i)
M = 10**9 + 7

CMB = Array.new
CMB << (x = 1)
(n - k).times do |i|
  CMB << (x = x * (i + k) / (i + 1) % M)
end
CMB.reverse!

a.sort!
fsum = CMB.lazy.zip(a, a.reverse_each).inject(0) { |sum, (cmb, min, max)| (sum + cmb * (max - min)) % M }

puts fsum
