#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

template <int MODULUS = 1000000007>
struct modulo_int {
private:

  long long value;
  constexpr void normalize() {
    value %= MODULUS;
    if (value < 0) value += MODULUS;
  }

public:

  constexpr modulo_int(const long long& value_ = 0) : value(value_) { normalize(); }
  constexpr modulo_int operator - () const { return modulo_int(MODULUS - value); }
  constexpr modulo_int operator ~ () const { return power(MODULUS - 2); }
  constexpr const long long& operator () () const { return value; }

  constexpr modulo_int operator + (const modulo_int& rhs) const { return modulo_int(*this) += rhs; }
  constexpr modulo_int& operator += (const modulo_int& rhs) {
    if ((value += rhs.value) >= MODULUS) value -= MODULUS;
    return (*this);
  }

  constexpr modulo_int operator - (const modulo_int& rhs) const { return modulo_int(*this) -= rhs; }
  constexpr modulo_int& operator -= (const modulo_int& rhs) {
    if ((value += MODULUS - rhs.value) >= MODULUS) value -= MODULUS;
    return (*this);
  }

  constexpr modulo_int operator * (const modulo_int& rhs) const { return modulo_int(*this) *= rhs; }
  constexpr modulo_int& operator *= (const modulo_int& rhs) {
    (value *= rhs.value) %= MODULUS;
    return (*this);
  }

  constexpr modulo_int operator / (const modulo_int& rhs) const { return modulo_int(*this) /= rhs; }
  constexpr modulo_int& operator /= (const modulo_int& rhs) {
    return (*this) *= ~rhs;
  }

  constexpr modulo_int power (const long long& pow) const {
    modulo_int result(1), mult(*this);
    for (long long t = pow; t > 0; t >>= 1) {
      if (t & 1) result *= mult;
      mult *= mult;
    }
    return result;
  }

  friend std::istream& operator >> (std::istream& stream, modulo_int& lhs) {
    stream >> lhs.value;
    lhs.normalize();
    return stream;
  }

  friend std::ostream& operator << (std::ostream& stream, const modulo_int& rhs) {
    return stream << rhs.value;
  }

};

template <int MODULUS = 1000000007>
struct modulo_fact {

  std::vector<modulo_int<MODULUS>> fact;
  std::vector<modulo_int<MODULUS>> ifact;

  modulo_fact(const int& size = 200000) : fact(size + 1), ifact(size + 1) {
    fact[0] = 1;
    for (int i = 1; i <= size; ++i) {
      fact[i] = fact[i - 1] * i;
    }
    ifact[size] = ~fact[size];
    for (int i = size; i > 0; --i) {
      ifact[i - 1] = ifact[i] * i;
    }
  }

  modulo_int<MODULUS> operator () (const int& n, const int& r) const {
    return fact[n] * ifact[r] * ifact[n - r];
  }

  modulo_int<MODULUS> perm(const int& n, const int& r) const {
    return fact[n] * ifact[n - r];
  }

};

using modint = modulo_int<>;
modulo_fact<> modfact;

int main() {

  int N, K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  rep (i, N) std::cin >> A[i];
  std::sort(all(A));

  modint ans;
  rep (i, N) {
    if (i + 1 >= K) {
      ans += modint(A[i]) * modfact(i, K - 1);
    }
    if (N - i >= K) {
      ans -= modint(A[i]) * modfact(N - i - 1, K - 1);
    }
  }

  std::cout << ans << '\n';
  return 0;

}


Measured memory_bytes: 3712