class Integer
  def inverse(m = nil)
    return Rational(1, self) if m.nil?

    # extended Euclidean algorithm
    a, b, u, v = self, m, 1, 0
    until b.zero?
      a, (t, b) = b, a.divmod(b)
      u, v = v, u - t * v
    end

    # u is an inverse iff self.gcd(m) == 1
    if a.abs != 1
      raise ArgumentError,
            "modulus is not coprime to the receiver" 
    end

    u = -u if a < 0
    u % m   # 0 <= u < m || m < u <= 0
  end
end

n, k, *a = $stdin.read.split.map(&:to_i)
M = 10**9 + 7

CMB = Array.new
CMB << (x = 1)
(n - k).times do |i|
  CMB << (x = x * (i + k) * (i + 1).inverse(M) % M)
end
CMB.reverse!

a.sort!
fsum = CMB.lazy.zip(a, a.reverse_each).inject(0) { |sum, (cmb, min, max)| (sum + cmb * (max - min)) % M }

puts fsum
