#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

#define INF (i64)1e18
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < n; i++)
#define RANGE(i, a, b) for(i64 i = a; i < b; i++)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

struct ModInt {
  i64 val;
  ModInt() {
    val = 0;
  }
  ModInt(i64 a) {
    val = mod(a);
  }
  inline i64 get() {
    return val;
  }
  inline operator i64(void) {
    return get();
  }
  inline i64 mod(i64 a) {
    a %= MOD;
    if (a < 0) a += MOD;
    return a;
  }
  inline ModInt &operator+=(ModInt a) {
    val = mod(val + a.val);
    return *this;
  }
  inline ModInt &operator-=(ModInt a) {
    val = mod(val - a.val);
    return *this;
  }
  inline ModInt &operator*=(ModInt a) {
    val = mod(val * a.val);
    return *this;
  }
  inline ModInt &operator/=(ModInt a) {
    return *this *= a.inv();
  }
  inline ModInt operator+(ModInt a) {
    return ModInt(*this) += a;
  }
  inline ModInt operator-(ModInt a) {
    return ModInt(*this) -= a;
  }
  inline ModInt operator*(ModInt a) {
    return ModInt(*this) *= a;
  }
  inline ModInt operator/(ModInt a) {
    return ModInt(*this) /= a;
  }
  inline ModInt operator-(void) {
    return ModInt(0 - val);
  }
  inline bool operator==(ModInt a) {
    return val == a.val;
  }
  inline bool operator!=(ModInt a) {
    return val != a.val;
  }
  inline ModInt &operator+=(i64 a) {
    return *this += ModInt(a);
  }
  inline ModInt &operator-=(i64 a) {
    return *this -= ModInt(a);
  }
  inline ModInt &operator*=(i64 a) {
    return *this *= ModInt(a);
  }
  inline ModInt &operator/=(i64 a) {
    return *this /= ModInt(a);
  }
  inline ModInt operator+(i64 a) {
    return ModInt(*this) += a;
  }
  inline ModInt operator-(i64 a) {
    return ModInt(*this) -= a;
  }
  inline ModInt operator*(i64 a) {
    return ModInt(*this) *= a;
  }
  inline ModInt operator/(i64 a) {
    return ModInt(*this) /= a;
  }
  inline bool operator==(i64 a) {
    return val == mod(a);
  }
  inline bool operator!=(i64 a) {
    return val != mod(a);
  }
  inline ModInt pow(i64 n) {
    ModInt a(*this);
    ModInt res = 1;
    while (n) {
      if (n & 1) {
        res *= a;
      }
      n >>= 1;
      a *= a;
    }
    return res;
  }
  inline ModInt inv() {
    return pow(MOD - 2);
  }
};

struct ModComb {
  i64 size;
  vector<ModInt> fact = {1};
  vector<ModInt> fact_inv = {1};
  ModComb() {
    size = 1;
  }
  inline void expand_fact(i64 n) {
    if (n <= size) return;
    RANGE(i, size, n) {
      fact.push_back(fact[i-1] * i);
      fact_inv.push_back(fact[i].inv());
    }
    size = n;
  }
  inline ModInt C(i64 n, i64 k) {
    if (k < 0 || k > n) return 0;
    expand_fact(n+1);
    return fact[n] * fact_inv[k] * fact_inv[n-k];
  }
  inline ModInt P(i64 n, i64 k) {
    if (k < 0 || k > n) return 0;
    expand_fact(n+1);
    return fact[n] * fact_inv[n-k];
  }
  inline ModInt H(i64 a, i64 b) {
    if (a == 0 && b == 0) return 1;
    if (a <= 0 || b < 0) return 0;
    expand_fact(a+b);
    return C(a+b-1, b);
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  vector<i64> a(n);
  for (auto& x : a) cin >> x;
  sort(ALL(a));

  ModInt ans = 0;
  ModComb c;
  REP(i, n) {
    ans -= c.C(n-i-1, k-1) * a[i];
    ans += c.C(i, k-1) * a[i];
  }
  cout << ans.val << endl;

  return 0;
}


Measured memory_bytes: 5872