#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (((x*f(x,y/2))%mod)*f(x,y/2))%mod;

}
int main(){
int64_t N,K;
  cin>>N>>K;
  vector<int64_t>A(N);
  for(int64_t i=i;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  int64_t a=1;
  for(int64_t i=K;i<=N;i++){
  ans=(ans+(a*(mod+A.at(i-1)-A.at(N-i)))%mod)%mod;
  a=(((a*i)%mod)*f(i-K+1,mod-2))%mod;
  
  }cout<<ans<<endl;
  
    return 0;
}
