fun main(args: Array<String>) {
    abc151e()
}

fun abc151e() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()

    var answer = 0L
    
    for (i in 0 until n) {
        answer -= aList[i] * nCk(n - i - 1, k - 1) % MOD
        answer += aList[i] * nCk(i, k - 1) % MOD
        answer %= MOD
    }


    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private const val MAX = 1000000
private val fac = LongArray(MAX)
private val fInv = LongArray(MAX)
private val inv = LongArray(MAX)
private var isNCkInit = false

private fun nCk(n: Int, k: Int): Long {
    if (!isNCkInit) {
        isNCkInit = true
        fac[0] = 1
        fac[1] = 1
        fInv[0] = 1
        fInv[1] = 1
        inv[1] = 1
        for (i in 2 until MAX) {
            fac[i] = fac[i - 1] * i % MOD
            inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD
            fInv[i] = fInv[i - 1] * inv[i] % MOD
        }
    }
    if (n < k) return 0
    if (n < 0 || k < 0) return 0
    return fac[n] * (fInv[k] * fInv[n - k] % MOD) % MOD
}
