const val mod = 1000000007L

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').let { it[0].toInt() to it[1].toInt() }
    val arr = readLine()!!.split(' ').map { it.toLong() }.sorted()
    val comb = FermatCombination(n, mod)
    val result = arr.foldIndexed(0L) { i, acc, v -> (acc + v * (comb.combine(i, k - 1) - comb.combine(n - i - 1, k - 1))) % mod }
    println(result)
}

class FermatCombination(size: Int, val mod: Long) {
    var factrial: LongArray = LongArray(size + 1)
    var inverse: LongArray = LongArray(size + 1)

    init {
        factrial[0] = 1
        inverse[0] = 1
        for (i in 1..size) {
            factrial[i] = factrial[i - 1] * i % mod
            inverse[i] = pow(factrial[i], mod.toInt() - 2) % mod
        }
    }

    fun combine(n: Int, k: Int): Long {
        if (n < k || n < 0 || k < 0) return 0
        return factrial[n] * inverse[k] % mod * inverse[n - k] % mod
    }

    fun pow(x: Long, n: Int): Long {
        var x = x
        var n = n
        var ans: Long = 1
        while (n > 0) {
            if (n and 1 == 1) {
                ans = ans * x % mod
            }
            x = x * x % mod
            n = n shr 1
        }
        return ans
    }
}
