n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
mod = 10**9 + 7
fact = [1]
cmb = ->(n, k){ n >= k ? fact[n] * (fact[n - k] * fact[k]).pow(mod - 2, mod) : 0 }
(1..n).each{|i| fact[i] = fact[i - 1] * i % mod }
ans = 0
n.times{|i| ans = (ans + a[i] * (cmb[i, k - 1] - cmb[n - i - 1, k - 1])) % mod }
puts ans
