import java.io.{BufferedReader, InputStreamReader}

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(n, k) = in.readLine().split("\\s+").map(_.toInt)
    val as = in.readLine().split("\\s+").map(_.toLong).sorted

    val MOD = 1000000007

    val combs = new mutable.HashMap[(Int, Int), Long]()

    def comb(n: Int, k: Int): Long = {
      if (n - k < k) {
        comb(n, n - k)
      } else {
        class Node(val n: Int, val k: Int, val parent: Option[Node]) {
          lazy val children: List[Node] = {
            if (k <= 0 || n == k) {
              Nil
            } else {
              List(
                new Node(n - 1, k - 1, Some(this)),
                new Node(n - 1, k, Some(this))
              )
            }
          }
          var c: Option[Long] = None
        }

        def inner(root: Node): Node = {
          var node: Node = root

          while (node != null) {
            val n = node.n
            val k = node.k

            combs.get((n, k)) match {
              case Some(c) =>
                node.c = Some(c)
                node.parent match {
                  case Some(p) => node = p
                  case None => node = null
                }
              case None =>
                if (node.children.isEmpty) {
                  node.c = Some(1)
                  combs.update((n, k), node.c.get)
                  node.parent match {
                    case Some(p) => node = p
                    case None => node = null
                  }
                } else {
                  node.children.find { child =>
                    child.c.isEmpty
                  } match {
                    case Some(unresolvedChild) =>
                      node = unresolvedChild
                    case None =>
                      node.c = Some(node.children.map(_.c).foldLeft(0L) {
                        case (sum, Some(c)) => (sum + c) % MOD
                        case _ => throw new Exception()
                      })
                      combs.update((n, k), node.c.get)
                      node.parent match {
                        case Some(p) =>
                          node = p
                        case None =>
                          node = null
                      }
                  }
                }
            }
          }

          root
        }

        inner(new Node(n, k, None)).c.get
      }
    }

    var sum = 0L

    for {
      s <- 0 to (n - k)
      e <- (s + k - 1) until n
    } {
      sum = (sum + ((as(e) - as(s)) % MOD * comb(e - s - 1, k - 2)) % MOD) % MOD
    }

    System.out.println(sum)
  }
}
