#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int inv[100005],finv[100005],f[100005];
int n,a[100005],mod=1000000007;
void C(){
	f[0]=1;finv[0]=1;finv[1]=1;f[1]=1;inv[1]=1;
	FOR(i,2,n){
		f[i]=f[i-1]*i%mod;
		inv[i]=mod-inv[mod%i]*(mod/i)%mod;
		finv[i]=finv[i-1]*inv[i]%mod; 
	}
}
int c(int n,int k){
	if(n<k)return 0;
	return f[n]*(finv[k]*finv[n-k]%mod)%mod;
}
signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);int k;
	cin>>n>>k;
	FOR(i,1,n)cin>>a[i];
	sort(a+1,a+n+1);
	C();
	int ans=0;
	FOR(i,1,n){
		ans+=c(i-1,k-1)*a[i]%mod;
		ans=(ans+mod)%mod;
		ans-=c(n-i,k-1)*a[i]%mod;
		ans=(ans+mod)%mod;
	}
	cout<<ans;
	return 0;
}


