object Main extends App {
  val Mod = 1000000007L
  val in = new java.util.Scanner(System.in)
  val N, K = in.nextInt
  val As = Array.fill(N)(in.nextInt).sorted
  val sums = for {
    l <- 0 to N - K
    r <- (l + K - 1) to N - 1
  } yield {
    val f = As(r) - As(l)
    (f * nCr(r - l - 1, K - 2)).toLong % Mod
  }

  def nCr(n: Int, r: Int): BigInt = {
    val numer = (n - r + 1 to n).foldLeft(1L)((z, i) => z * i % Mod)
      (2 to r).foldLeft(BigInt(numer))((z, i) => BigInt(i).modInverse(Mod) * z % Mod)
  }
  println(sums.foldLeft(0L)((z, s) => (z + s) % Mod))
}