#include<bits/stdc++.h>
using namespace std;
int64_t mod=1000000007;
vector<int64_t> fact(100001),factinv(100001);
int64_t pow(int64_t x,int64_t y){
  int64_t z; 
  if(y==0) return 1;
  else{
    z=((pow(x,y/2)+mod)%mod)*((pow(x,y/2)+mod)%mod)%mod;
    if(y%2==1) z=z*x%mod;
    return (z+mod)%mod;
  }
}
int64_t comb(int64_t n,int64_t k){
  int64_t a,i;
  if(n<k) return 0;
  else{
    a=(fact.at(n)+mod)%mod;
    a=(a*factinv.at(k)+mod)%mod;
    a=(a*factinv.at(n-k)+mod)%mod;
    return (a+mod)%mod;
  }
}
int main(){
  int64_t n,k,i,ans=0;
  cin>>n>>k;
  vector<int64_t> a(n);
  for(i=0;i<n;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  fact.at(0)=1;
  factinv.at(0)=1;
  for(i=1;i<=n;i++){
    fact.at(i)=fact.at(i-1)*i%mod;
    factinv.at(i)=(factinv.at(i-1)*pow(i,mod-2)+mod)%mod;
  }
  for(i=0;i<n;i++) ans+=(comb(i,k-1)-comb(n-1-i,k-1))*a.at(i)%mod;
  cout<<(ans+mod)%mod<<endl;
}