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


puts ans % (10**9+7)
