import java.util.*

fun main(args:Array<String>){
    val (n,k) = readLine()!!.split(" ").map{it.toInt()}
    val a = readLine()!!.split(" ").map{it.toLong()}.toLongArray()
    a.sort()
    var ma = 0L
    var mi = 0L
    val mod = 1000000007L
    val c = comb(n,mod)
    c.init()
    for(i in k - 1 until n){
        ma += c.calc(i, k - 1) * a[i] % mod
        ma %= mod
    }
    for(i in 0 .. n - k){
        mi += (c.calc(n - i - 1, k - 1) * a[i] % mod + mod) % mod
        mi %= mod
    }
    println((ma - mi + mod) % mod)
}

class comb{
    val n : Int
    val mod : Long
    val f : LongArray
    val rf : LongArray
    constructor(n : Int, m : Long){
        this.n = n
        this.mod = m
        this.f = LongArray(n + 1)
        this.rf = LongArray(n + 1)
    }

    fun inv(x : Long) : Long{
        var ret = 1L
        var k = mod - 2
        var y = x
        while(k > 0){
            if(k and 1L == 1L) ret = (ret * y) % mod
            y = (y * y) % mod
            k /= 2
        }
        return ret
    }

    fun init(){
        f[0] = 1
        for(i in 1 .. n) f[i] = (f[i - 1] * i) % mod
        for(i in 0 .. n) rf[i] = inv(f[i])
    }

    fun calc(n : Int, k : Int) : Long{
        if(n > this.n || n < 0 || k > this.n || k < 0 || n < k) return 1L
        val a = f[n]
        val b = rf[n - k]
        val c = rf[k]
        val bc = (b * c) % mod
        return (a * bc) % mod
    }
}