#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long LL;
const LL maxn(100005), mod(1e9 + 7);
LL Jc[maxn];
int a[N];

void calJc()    
{
    Jc[0] = Jc[1] = 1;
    for(LL i = 2; i < maxn; i++)
        Jc[i] = Jc[i - 1] * i % mod;
}

LL pow(LL a, LL n, LL p)    //??? a^n % p
{
    LL ans = 1;
    while(n)
    {
        if(n & 1) ans = ans * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return ans;
}

LL niYuan(LL a, LL b)   //????????
{
    return pow(a, b - 2, b);
}

LL C(LL a, LL b)    //??C(a, b)
{
    return Jc[a] * niYuan(Jc[b], mod) % mod
        * niYuan(Jc[a - b], mod) % mod;
}
int main(){
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	calJc();
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	LL ans=0;
	for(int i=k;i<=n;i++){
		LL c=C(i-1,k-1);
		ans=(ans+c*a[i]%mod)%mod;
		ans=(ans-c*a[n-i+1]%mod+mod)%mod;
	}
	cout<<ans;
	return 0;
}