#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int p(int A,int B){
  if(B==0)return 1;
  if(B%2)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N),B(100010);
  for(int &i:A)cin>>i;
  sort(A.begin(),A.end());
  B[0]=1;
  for(int i=1;i<=100000;i++)B[i]=B[i-1]*i%mod;
  int mx=0,mn=0;
  for(int i=0;i<N;i++){
    if(i>=K-1)mx=(mx+B[i]*p(B[i-K+1]*B[K-1]%mod,mod-2)%mod*A[i]%mod)%mod;
    if(N-i>=K)mn=(mn+B[N-1-i]*p(B[N-i-K]*B[K-1]%mod,mod-2)%mod*A[i]%mod)%mod;
  }
  cout<<(mx-mn+mod)%mod<<endl;
}