MOD = 10**9+7
ONE = '1'.freeze
def inv(x)
    res = 1 # 逆元をどんどんかけるやつ
    beki = x # 逆元を計算したい値のMOD化でのべき乗
    (MOD - 2).to_s(2).reverse.chars do |digest|
        res = (beki * res) % MOD if digest == ONE
        beki = (beki * beki) % MOD
    end
    res
end

str = gets.split
N,K = str[0].to_i, str[1].to_i
a = Array.new(N)
str = gets.split
for i in 0...N do
    a[i] = str[i].to_i
end
a.sort!

answer = 0
s = 1
for i in K..N do
    b = (a[-i] * s) % MOD
    answer -= b
    answer += MOD
    answer %= MOD
    s *= i
    s *= inv(i-K+1)
    s %= MOD
end
a.reverse!
s = 1
for i in K..N do
    b = (a[-i] * s) % MOD
    answer += b
    answer %= MOD
    s *= i
    s *= inv(i-K+1)
    s %= MOD
end
puts answer