m = mod = 10 ** 9 + 7

class Combination
  
  attr_accessor :n_max, :mod
  
  def initialize(n_max,mod)
    @n_max, @mod = n_max, mod
    @fact = [1, 1]
    @inv = [0,1]
    @factinv = [1, 1]
    f(2, n_max)
  end
  
  def f(s,t)
    @n_max = t
    s.upto(t) do |i|
      @fact.push( @fact[-1] * i % mod )
      @inv.push( -@inv[mod % i] * (mod / i) % mod )
      @factinv.push( @factinv[-1] * @inv[-1] % mod )
    end
  end
  
  def cmb(n,r,mod)
    return 0 if r < 0 || n < r
    f(n_max+1, n) if n_max < n
    @fact[n] * (@factinv[r] * @factinv[n-r] % mod) % mod
  end
end

ans = 0

n, k = gets.to_s.split.map{|i|i.to_i}
a    = gets.to_s.split.map{|i|i.to_i}.sort

inst = Combination.new(n, m)

(n-k+1).times do |i|
  t = inst.cmb( n-i-1, k-1, mod)
  mi = a[i] * t % m
  ma = a[n-(i+1)] * t % mod
  ans += (ma - mi)
  ans %= m if ans < 0 || m <= ans
end

puts ans