n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort

mod = 10 ** 9 + 7
fac = [1]
1.upto(n-1) {|i| fac << fac[i-1] * i % mod}

rfac = Array.new(n,1)
t = fac[n-1]
"111011100110101100101000000101".reverse.each_char do |c|
    rfac[n-1] = (rfac[n-1] * t) % mod if (c == '1')
    t = t ** 2 % mod
end
(n-2).downto(0) {|i| rfac[i] = rfac[i+1] * (i+1) % mod}

ans = 0
n.times do |i|
    if i > n - k && i < k - 1
        next
    elsif i < k - 1
        ans = (ans - a[i] * fac[n-i-1] * rfac[k-1] * rfac[n-i-k]) % mod
    elsif i > n - k
        ans = (ans + a[i] * fac[i] * rfac[k-1] * rfac[i-k+1]) % mod
    else
        ans = (ans - a[i] * fac[n-i-1] * rfac[k-1] * rfac[n-i-k]) % mod
        ans = (ans + a[i] * fac[i] * rfac[k-1] * rfac[i-k+1]) % mod
    end
end

puts ans