object Main {
    val mod: Long = (1e9 + 7).toLong
    val fct: Array[Int] = new Array[Int]( (1e5 + 5).toInt )
    val ifct: Array[Int] = new Array[Int]( (1e5 + 5).toInt )

    def power(x: Long, y: Long):Long = {
        if(y <= 0)  return 1
        var ans: Long = power( (x * x) % mod, y >> 1 )
        if( (y & 1) > 0 ) ans = (ans * x) % mod
        return ans
    }

    def factorials(n: Int) = {
        fct(0) = 1
        for(i <- 1 to n) fct(i) = ((1L * i * fct(i-1)) % mod).toInt
        ifct(n) = power(fct(n), mod - 2).toInt
        for(i <- (n-1) to 0 by -1) ifct(i) = ( (1L * (i+1) * ifct(i+1)) % mod ).toInt
    }

    def cmb(n: Int, k: Int): Int = {
        if(n < 0 || k < 0 || n < k) return 0
        var ans: Long = (1L * fct(n) * ifct(k)) % mod
        ans = (ans * ifct(n-k)) % mod
        return ans.toInt
    }

    def main(args: Array[String]) = {
        import scala.io.StdIn.readLine
        var Array(n, k) = readLine.split(" ").map(_.toInt)
        var a: Array[Int] = readLine.split(" ").map(_.toInt)
        factorials(n)

        a = a.sorted
        var ans: Int = 0
        for(i <- 0 until n) {
            val maxes = cmb(i, k - 1)
            val mins = cmb(n - i - 1, k - 1)
            val add = ((maxes - mins + mod) % mod).toInt
            ans = ans + ((1L * add * a(i)) % mod).toInt
            if(ans >= mod)  ans = ans - mod.toInt
        }
        printf("%d\n", ans)
    }
}
