#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+5;
const int mod=1e9+7;
int n,k,f[maxn],inv[maxn],front[maxn],a[maxn];
int quick_pow(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
			(res*=a)%=mod;
		(a*=a)%=mod;
		b>>=1;
	}
	return res;
}
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
signed main()
{
	ios::sync_with_stdio(0);
//    fl();
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	if(k==1)
	{
		cout<<0<<endl;
		return 0;
	}
	sort(a+1,a+n+1);
	f[1]=1;
	for(int i=2;i<=n;i++)
		f[i]=f[i-1]*i%mod;
	inv[n]=quick_pow(f[n],mod-2);
	for(int i=n-1;i>=1;i--)
		inv[i]=(inv[i+1]*(i+1)%mod);
//	for(int i=1;i<=n;i++)
//	{
//		cout<<inv[i]<<" ";
//		cout<<inv[i]*f[i]%mod<<endl;
//	}
//	cout<<endl;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int large,small;
		if(n-i<k-1)
			small=0;
		else if(k-1==0||k-1==n-i)
			small=1;
		else
			small=f[n-i]*inv[n-i-k+1]%mod*inv[k-1]%mod;
		if(i-1<k-1)
			large=0;
		else if(k-1==0||k-1==i-1)
			large=1;
		else
			large=f[i-1]*inv[i-1-k+1]%mod*inv[k-1]%mod;
//		cout<<small<<" "<<large<<endl;
		(ans+=(large-small)*a[i]%mod)%=mod;
	}
	cout<<ans<<endl;
	return 0;
}
