mod = 10 ** 9 + 7

class Facts
  
  def initialize(mod=10**9+7, n_max=1)
    @mod = mod
    @n_max = n_max
    @fact = [1, 1]
    @inv = [0,1]
    @factinv = [1, 1]
    setup_table(t) if 1 < @n_max 
  end
  
  def cmb(n,r)
    return 0 if r < 0 || n < r
    setup_table(n) if @n_max < n
    @fact[n] * (@factinv[r] * @factinv[n-r] % @mod) % @mod
  end
  
  def factorial(n)
    setup_table(n) if @n_max < n
    @fact[n]
  end
  
  def prm(n,k)
    setup_table(n) if @n_max < n
    @fact[n] * @factinv[n-k] % @mod
  end
  
  private
  def setup_table(t)
    (@n_max+1).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
    @n_max = t
  end
end

mod = 10 ** 9 + 7

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

f = Facts.new

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