#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

const ll mod=1e9+7;

ll modcom(ll N, ll K, ll L) {
  if(N<=0||K<=0||L<=0) return 0;
  ll d=1,e = (L*K)%mod, m_ = mod-2;
  while(m_ != 0) {
    if (m_&1) d = (d*e)%mod;
    e = e*e%mod;
    m_ = m_ >> 1;
  }
  return (N*d)%mod;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,mx,mn,ans=0;cin>>n>>k;
  lvector A(n,0);rep(i,n) cin>>A[i];
  sort(A.begin(),A.end());
  lvector V(n+1,1);
  for(ll i=1;i<=n;++i) V[i]=i*V[i-1]%mod;
  for(ll i=0;i<n;++i) {
    mx=0, mn=0;
    if(i>0&&i-k+1>=0) mx=modcom(V[i],V[i-k+1],V[k-1]);
    if(n-1-i>0&&n-i-k>=0) mn=modcom(V[n-1-i],V[n-i-k],V[k-1]);
    ans=(ans+A[i]*(mx-mn)%mod)%mod;
  }
  print(ans);
  return 0;
}
