import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readIntegerList()
    val aList = readLongList().sorted()

    val mod = 1000000007L
    val combination = Combination(n, mod)

    var minSum = 0L
    for ((i, a) in aList.dropLast(k - 1).withIndex()) {
        val right = n - i - 1
        val comb = combination.value(right, k - 1)
        minSum = (minSum + ((a * comb) % mod)) % mod
    }

    var maxSum = 0L
    for ((i, a) in aList.drop(k - 1).withIndex()) {
        val left = k - 1 + i
        val comb = combination.value(left, k - 1)
        maxSum = (maxSum + ((a * comb) % mod)) % mod
    }

    var ans = (maxSum  - minSum) % mod
    if (ans < 0) {
        ans += mod
    }
    out.println(ans)
}

/** n <= 20000000
 * MODは素数（フェルマーの小定理を利用するため）
 */
class Combination(n: Int = 20000000, val MOD: Long = 1000000007L) {
    val fact = LongArray(n + 1)
    val ifact = LongArray(n + 1)

    /** O(n) */
    init {
        fact[0] = 1L
        for (i in 1..n) { fact[i] = (fact[i - 1] * i) % MOD }
        ifact[n] = inverse(fact[n], MOD)
        for (i in n downTo 1) { ifact[i - 1] = (ifact[i] * i) % MOD }
    }

    /** O(1) */
    fun value(n: Int, k: Int) = if (k < 0 || k > n) 0 else (((fact[n] * ifact[k]) % MOD) * ifact[n-k]) % MOD

    /** O(log(m)) */
    fun pow(n: Long, m: Long, MOD: Long): Long {
        var ret = 1L
        var x = n
        var k = m
        while (k > 0) {
            if ((k and 1L) == 1L) { ret = (ret * x) % MOD }
            x = (x * x) % MOD
            k = k shr 1
        }
        return ret
    }

    /** O(log(MOD)) */
    fun inverse(n: Long, MOD: Long) = pow(n, MOD - 2L, MOD)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)
