#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MOD = 1e9+7, MAX_N = 1e5+2;
int N, K;
int a[MAX_N];
ll fac[MAX_N],inv[MAX_N];

ll powmod(ll x, ll y)
{
	ll res=1;
	while(y){
		if(y&1)(res*=x)%=MOD;
		(x*=x)%=MOD;
		y>>=1;
	}
	return res;
}

ll nCk(ll n, ll k)
{
	if(k<0||k>n) return 0;
	return (((fac[n]*inv[k])%MOD)*inv[n-k])%MOD;
}

void solve()
{
	if(K==1){
		cout << 0 << '\n';
		return;
	}
	fac[0] = fac[1]= 1;
	for(int i=2;i<=N;++i) fac[i]=(1LL*i*fac[i-1])%MOD;
	inv[N]=powmod(fac[N],MOD-2);
	for(int i=N-1;i>=0;--i)inv[i]=(1LL*(i+1)*inv[i+1])%MOD;
	sort(a,a+N);
	ll ans = 0;
	for(int i=K-1;i<N;++i)  ans=(ans+a[i]*nCk(i,K-1))%MOD;
	for(int i=N-K;i>=0;--i) ans=(ans-a[i]*nCk(N-i-1,K-1)+MOD)%MOD;
	cout << ans << '\n';
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N;++i) cin >> a[i];
	solve();
	return 0;
}