n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a.sort!{|a,b| b<=>a}
ans = 0
com = Array.new(n-k+1)
com[0] = 1
time = 0
(k-1).upto(n-2) do |i|
    com[i-k+2] = com[i-k+1]*(i+1)/(i+2-k)
end
(n-k).downto(0) do |i|
    ans += (a[i]*com[n-k-i])
end
(k-1).upto(n-1) do |i|
    ans += (a[i]*com[i-k+1]*(-1))
end

puts ans % (10**9+7)
