import java.io.*
import java.util.*

const val MOD = 1000000007L
fun solve(N: Int, K: Int, A: LongArray) {
    // Sum[i in 0..N-1, j in i+k..N-1](Aj - Ai) * j-i-1 C k-2
    // j-i=pを固定する p in k..N-k-1
    if (K == 1) {
        println(0)
        return
    }
    A.sort()
    val accSum = A.toList().scanLeft(0L) { a, b -> a + b }.toList()
    val invs = calcModInvs(N, MOD)
    val binomials = LongArray(N) // i C K-2
    binomials[K - 2] = 1L
    for (i in K - 1 until N) {
        // i C k - 2 = i-1 C k-2 * i/(i - k + 2)
        binomials[i] = (((binomials[i - 1] * i) % MOD) * invs[i - K + 2]) % MOD
    }
    // println(invs.toList())
    // println(binomials.toList())
    var ans = 0L
    for (p in K - 1 until N) {
        val ret = ((accSum[N - 1] - accSum.getOrElse(p - 1) { 0L } - accSum.getOrElse(N - p - 1) { 0L }) % MOD) * binomials[p - 1]
        ans = (ans + ret % MOD) % MOD
    }
    println(ans)
    return
}

fun calcModInvs(num: Int, mod: Long): LongArray {
    // num以下のmodで割った余りの逆元を計算
    val invs = LongArray(num + 1)
    invs[1] = 1L
    for (i in 2L..num.toLong()) {
        invs[i.toInt()] = (invs[(mod % i).toInt()] * (mod - mod / i)) % mod
    }
    return invs
}

fun <T, R> Iterable<T>.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence<R> {
    var last = initial
    return this.asSequence().map { last = operation(last, it); last }
}
fun Long.modPow(x: Long, mod: Long): Long {
    // this ^ x % mod
    tailrec fun binModPow(a: Long, exp: Long): Long = when (exp) {
        // a ^ (2^(exp)) % mod
        0L -> a % mod
        else -> binModPow(a * a % mod, exp - 1)
    }
    return (0..63).asSequence()
        .map { (x shr it) and 1 }
        .withIndex()
        .filter { it.value > 0 }
        .map { binModPow(this, it.index.toLong()) }
        .reduce { a, b -> a * b % mod }
}

// 1 / x % mod (x ⊥ mod)
fun Long.modInv(mod: Long): Long = this.modPow(mod - 2, mod)

fun binomialMod(n: Int, k: Int, mod: Long): Long = when (k) {
    // nCk % mod
    0, n -> 1L
    else -> {
        val numer = (n downTo n - k + 1)
            .map { it.toLong() }
            .reduce { a, b -> (a * b) % mod }
        val denom = (1..k)
            .map { it.toLong() }
            .reduce { a, b -> (a * b) % mod }
        (numer * denom.modInv(mod)) % mod
    }
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val K = sc.next().toInt()
    val A = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        A[i] = sc.next().toLong()
    }
    solve(N, K, A)
}
