const val mod = 1000000007L

fun modpow(n:Long,p:Long = mod-2L):Long = when {
	p==0L->1L
	p%2==1L->n*modpow(n,p-1)%mod
	else-> {
		val d = modpow(n,p/2)
		d*d%mod
	}
}

fun nCr(n:Int,r:Int,modpowCache:Long):Long = (n-r+1L..n).asSequence().fold(modpowCache) {a,b-> a*b%mod}
fun modpowCache(r:Int) = (2L..r).asSequence().map {modpow(it.toLong())}.fold(1L) {a,b-> a*b%mod}

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

fun abc000X() {
	val s = java.util.Scanner(System.`in`)
	val n = s.nextInt()
	val k = s.nextInt()
	if(k==1) {
		println(0)
		return
	}
	val a = LongArray(n) {s.nextLong()}.sorted()

	val modpowCache = modpowCache(k-2)
	val cache:LongArray = when {
		k<3->LongArray(n-1) {modpowCache}
		else-> {
			val t = LongArray(n-1) {0L}
			t[k-2] = nCr(k-2,k-2,modpowCache)
			for(i in k-1..n-2) {
				t[i] = t[i-1]*i%mod*modpow(i-k+2L)%mod
			}
			t
		}
	}

	for(i in 1..n-2)
		cache[i] = (cache[i]+cache[i-1])%mod

	var r = 0L
	for(i in a.indices) {
		val l = if(i-1<0) 0 else cache[i-1]
		val m = if(n-2-i<0) 0 else cache[n-2-i]
		r = ((l-m+mod)%mod*a[i]%mod+r+mod)%mod
	}
	println(r)
}
