#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <queue>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
lll combi(lll n, lll k) {
    lll r = 1, rr = 1;
    for(lll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
         //r %= 1000000007;
         //rr %= 1000000007;
    }
    r /= rr;
     //r %= 1000000007;
    return r;
}
int main(){
  lll N,K;
  cin>>N>>K;
  if(K==1){
    cout<<0<<endl;
    return 0;
  }
  vector<ll> A((ll)N);
  FOR(i,(ll)N){
    cin>>A[i];
  }
  lll min_=0,max_=0;
  sort(A.begin(),A.end());
  //lll c = combi(N-1,K-1);
  lll c=1;
  lll ii=1;
  for(lll i=N-K;i>=0;--i){
    min_+=(c%1000000007)*A[(ll)i];
    min_%=1000000007;
    max_+=(c%1000000007)*A[(ll)(N-1-i)];
    max_%=1000000007;
    c*=(ii+K-1);
    c/=(ii);
    ii+=1;
    //cout<<c<<endl;
  }
  
  cout<<(max_-min_)%1000000007<<endl;
  return 0;
}
