#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template <int T_MOD>
struct ModInt {
  static constexpr int MOD = T_MOD;
private:
  using ll = long long;
  int v;

  static int minv(int a, int m) {
    a %= m;
    if (a < 0) a += m;
    int b = m, u = 0, v = 1;
    while (a) {
      int t = b / a;
      b -= t * a; swap(a, b);
      u -= t * v; swap(u, v);
    }
    assert(b == 1);
    if (u < 0) u += m;
    return u;
  }

public:

  ModInt() : v(0) {}
  template<class T> ModInt(T v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
  explicit operator int() const { return v; }
  friend std::ostream& operator << (std::ostream& out, const ModInt& n) { return out << int(n); }
  friend std::istream& operator >> (std::istream& in, ModInt& n) { ll v_; in >> v_; n = ModInt(v_); return in; }
  friend bool operator == (const ModInt& a, const ModInt& b) { return a.v == b.v; }
  friend bool operator != (const ModInt& a, const ModInt& b) { return a.v != b.v; }

  ModInt inv() const {
    ModInt res;
    res.v = minv(v, MOD);
    return res;
  }

  ModInt neg() const {
    ModInt res;
    res.v = v ? MOD - v : 0;
    return res;
  }

  ModInt operator- () const {
    return neg();
  }

  ModInt operator+ () const {
    return ModInt(*this);
  }

  ModInt& operator ++ () {
    v++;
    if (v == MOD) v = 0;
    return *this;
  }

  ModInt& operator -- () {
    if (v == 0) v = MOD;
    v --;
    return *this;
  }

  ModInt& operator += (const ModInt& o) {
    v += o.v;
    if (v >= MOD) v -= MOD;
    return *this;
  }

  ModInt& operator -= (const ModInt& o) {
    v -= o.v;
    if (v < 0) v += MOD;
    return *this;
  }

  ModInt& operator *= (const ModInt& o) {
    v = int(ll(v) * ll(o.v) % MOD);
    return *this;
  }

  ModInt& operator /= (const ModInt& o) {
    return *this *= o.inv();
  }

  friend ModInt operator ++ (ModInt& a, int) { ModInt r = a; ++a; return r; }
  friend ModInt operator -- (ModInt& a, int) { ModInt r = a; --a; return r; }
  friend ModInt operator + (const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
  friend ModInt operator - (const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
  friend ModInt operator * (const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
  friend ModInt operator / (const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }  
};

const int mod = 1000000007;
using Mint = ModInt<mod>;

Mint power(Mint x, int p) {
  Mint ans = Mint(1);
  while(p) {
    if(p & 1) {
      ans *= x;
    }
    x *= x;
    p >>= 1;
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  Mint max = 0, min = 0;
  int n, k; cin >> n >> k;
  vector<Mint> fact(n + 1), ifact(n + 1);
  fact[0] = 1; ifact[0] = 1;
  for(int i = 1; i <= n; ++i) {
    fact[i] = Mint(i) * fact[i - 1];
    ifact[i] = 1 / fact[i];
  }
  vector<int> ar(n);
  for(int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  auto C = [&](int n, int k) {
    if(k > n || std::min(n, k) < 0) return Mint(0);
    return fact[n] * (ifact[k] * ifact[n - k]);
  };
  sort(ar.begin(), ar.end());
  for(int i = 0; i < n; ++i) {
    max += ar[i] * C(i, k - 1);
    min += ar[i] * C(n - 1 - i, k - 1);
  }
  cout << max - min << '\n';
  return 0;
}


Measured memory_bytes: 1408