// Slower C++ solution:
#include <bits/stdc++.h>

#define ALL(a)  (a).begin(),(a).end()

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

typedef pair<long long, long long> Pll;

typedef vector<int> vi;

typedef vector<vector<int>> vvi;

typedef vector<long long> vll;

typedef vector<vector<long long>> vvll;

template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

const int INT_INF = 1 << 30;

#define MOD 1000000007LL

#define endl "\n"



struct mint{

  ll x;

  mint(ll x = 0): x((x % MOD + MOD) % MOD){}

  mint operator-() const {return mint(-x);}

  mint& operator+=(const mint a){

    if((x += a.x) >= MOD) x -= MOD;

    return *this;

  }

  mint& operator-=(const mint a){

    if((x += MOD - a.x) >= MOD) x-= MOD;

    return *this;

  }

  mint& operator*=(const mint a){

    (x *= a.x) %= MOD;

    return *this;

  }

  mint operator+(const mint a){

    mint res(*this);

    return res+=a;

  }

  mint operator-(const mint a){

    mint res(*this);

    return res-=a;

  }

  mint operator*(const mint a){

    mint res(*this);

    return res*=a;

  }

  mint pow(ll t) const {

    if(!t) return 1;

    mint a = pow(t>>1);

    a *= a;

    if(t&1) a *= *this;

    return a;

  }



  // for prime mod

  mint inv() const {

    return pow(MOD-2);

  }

  mint& operator/=(const mint a){

    return (*this) *= a.inv();

  }

  mint operator/(const mint a){

    mint res(*this);

    return res/=a;

  }

};

struct combination{

  vector<mint> fact, ifact;

  combination(int n): fact(n+1), ifact(n+1){

    assert(n < MOD);

    fact[0] = 1;

    for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;

    ifact[n] = fact[n].inv();

    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;

  }

  mint operator()(int n, int k){

    if(k < 0 || k > n) return 0;

    return fact[n]*ifact[k]*ifact[n-k];

  }

};



int main(){

  ios::sync_with_stdio(false);

  cin.tie(nullptr);

  combination c(100010);

  ll N, K;

  cin >> N >> K;

  vll A(N);

  for(int i = 0; i < N; i++){

    cin >> A.at(i);

  }

  sort(ALL(A));

  mint ans;

  for(int i = 0; i < N; i++){

    mint plus, minus;

    if(i >= K - 1){

      plus += c(i, K-1);

    }

    if(i + K - 1 < N){

      minus += c(N-i-1, K-1);

    }

    ans += mint(A.at(i)) * (plus - minus);

    

  }

  cout << ans.x << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.1311951865521421x):
#include <bits/stdc++.h>

#define ALL(a)  (a).begin(),(a).end()

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

typedef pair<long long, long long> Pll;

typedef vector<int> vi;

typedef vector<vector<int>> vvi;

typedef vector<long long> vll;

typedef vector<vector<long long>> vvll;

template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

const int INT_INF = 1 << 30;

#define MOD 1000000007LL

#define endl "\n"



struct COM{

  ll modbeki(ll x, ll nn){

    ll res = 1;

    while(nn > 0){

      if(nn & 1) res = res * x % MOD;

      x = x * x % MOD;

      nn >>= 1;

    }

    return res;

  }

  vll fact, ifact;

  COM(ll n): fact(n+1), ifact(n+1){

    assert(n < MOD);

    fact[0] = 1LL;

    for(ll i = 1; i <= n; i++) fact[i] = fact[i-1]*i%MOD;

    ifact[n] = modbeki(fact[n], MOD-2);

    for(ll i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i%MOD;

  }

  ll operator()(int n, int k){

    if(k < 0 || k > n) return 0;

    return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;

  }

};



int main(){

  ios::sync_with_stdio(false);

  cin.tie(nullptr);

  COM c(100010);

  ll N, K;

  cin >> N >> K;

  vll A(N);

  for(int i = 0; i < N; i++){

    cin >> A.at(i);

  }

  sort(ALL(A));

  ll ans = 0;

  for(int i = 0; i < N; i++){

    ll plus = 0, minus = 0;

    if(i >= K - 1){

      plus += c(i, K-1);

      plus %= MOD;

    }

    if(i + K - 1 < N){

      minus += c(N-i-1, K-1);

      minus %= MOD;

    }

    ans += A.at(i) * (plus - minus) % MOD;

    (ans += MOD) %= MOD;

  }

  cout << ans << endl;

}