#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int exgcd(int a,int b,int &x,int &y){
	while(b){
		int t{a/b};
		swap(a-=t*b, b);
		swap(x-=t*y, y);
	}
	return a;
}
int exgcd(int a,int b){
	int x{1},y{0};
	return exgcd(a,b,x,y);
}
int inverse(int a,int mod){
	int x{1},y{0};
	exgcd(a,mod,x,y);
	return (x%mod+mod)%mod;
}

int main(){
	
	int n, k; cin>>n>>k;
	vector<int>a(n);
	for(auto &i:a)cin>>i;
	sort(a.begin(),a.end());
	ll ans{};
	vector<ll> c(n);
	k--;
	c.at(k)=1;
	
	for(int i=k+1; i<n; i++){
		c.at(i) = (c.at(i-1)*(i)%MOD*inverse(i-k,MOD))%MOD;
	}
	for(int i=k; i<n; i++){
		ans += c.at(i)*a.at(i);
		ans=(ans%MOD+MOD)%MOD;
	}
	for(int i=0; i+k<n; i++){
		ans -= c.at(n-i-1)*a.at(i);
		ans=(ans%MOD+MOD)%MOD;
	}
	cout << ans << endl;
	
}
