MOD = 10 ** 9 + 7
MAX = 10 ** 5

def com_init
  @fac = []
  @inv = []
  @finv = []
  @fac[0] = @fac[1] = 1
  @finv[0] = @finv[1] = 1
  @inv[1] = 1

  2.upto(MAX) 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 comb(n, k)
  return @fac[n] * ( @finv[k] * @finv[n - k] % MOD) % MOD
end

def main
  n, k = gets.chomp.split().map(&:to_i)
  array = gets.chomp.split.map(&:to_i).sort

  com_init()
  ans = 0
  
  (n - k + 1).times do |i|
    com = comb(n - i - 1, k - 1)
    ans += array[n - i - 1] * com % MOD
    ans -= array[i] * com % MOD
  end

  return ans % MOD
end

puts main