MOD = 10**9+7
def inverse(x)
    inv = 1
    inn = x
    (MOD-2).to_s(2).reverse.chars do |z|
        inv = (inv * inn)% MOD if z == '1'
        inn = (inn * inn)% MOD
    end
    inv
end
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a.sort!.reverse!
ans = 0
com = 1

(1).upto(n-k+1) do |i|
    ans += (a[n-k+1-i]*com)%MOD
    ans -= (a[i+k-2]*com)%MOD
    com = (com * (i+k-1) *  inverse(i) )% MOD 
end
puts ans % MOD