#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
ll mod=1e9+7;
ll inv(ll a){
    ll n=mod-2,ans=1;
    while(n>0){
        if(n&1) ans=ans*a%mod;
        n=n/2;
        a=a*a%mod;
    }
    return ans;
}
ll A[200001];
void init(){
    A[0]=1;
    rep(i,200000) A[i+1]=A[i]*(i+1)%mod;
}
ll nCk(ll n,ll k){
    return A[n]*inv(A[k])%mod*inv(A[n-k])%mod;
}
int main(){
    init();
    ll n,k,B[200001];
    cin>>n>>k;
    rep(i,n) cin>>B[i];
    if(k==1){cout<<0;return 0;}
    sort(B,B+n);
    ll C[200001];
    C[0]=0;
    rep(i,n) C[i+1]=(C[i]+B[i]+mod)%mod;
    ll ans=0;
    for(int i=n;i>=k;i--){
        ans+=nCk(i-2,k-2)*((C[n]-C[i-1]+mod)%mod-(C[n-i+1]-C[0]+mod)%mod+mod)%mod;
    }
    cout<<ans%mod<<"\n";
}
