class Combinator
  MAX = 110000 # nCkの最大のnより大きいこと。MODより小さいこと。
  MOD = 1000000007

  def initialize
    @fac = Array.new(MAX)
    @fac[0] = 1
    @fac[1] = 1
    @finv = Array.new(MAX)
    @finv[0] = 1
    @finv[1] = 1
    @inv = Array.new(MAX)
    @inv[1] = 1
    (2..(MAX-1)).each do |i|
      @fac[i] = @fac[i-1]*i%MOD
      @inv[i] = MOD-@inv[MOD%i]*(MOD/i)%MOD
      @finv[i] = @finv[i-1]*@inv[i]%MOD
    end
  end

  def call(all, select)
    return 0 if all < select
    return 0 if all < 0 || select < 0
    @fac[all] * (@finv[select] * @finv[all-select] % MOD) % MOD
  end
end
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
sum = 0
com = Combinator.new
a.each.with_index do |ai, idx|
  p = com.call(idx, k-1) - com.call(n-1-idx, k-1)
  sum += ((ai % 1000000007) * (p % 1000000007)) % 1000000007
  sum %= 1000000007
end
puts sum