#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

template<typename T = int64_t>
struct Combination
{
public:

  /** 符号付き整数を推奨 */
  using com_int = T;

  /** 特に必要はない */
  int mInf;

  /** modを取るので */
  com_int mMod;

  /** (n!)のメモ帳 */
  vector<com_int> fac;

  /** modinvするので */
  vector<com_int> inv;

  /** (k!)^-1のメモ帳 */
  vector<com_int> finv;

  /**
   * @param N nCkで指定するnの最大（デフォルト値は何となく）
   * @param m modを取るので（デフォルト値は10^9 + 7）
   */
  Combination(int N = 10^5, int m = MOD)
    : mInf(N)
    , mMod(m)
    , fac(N+1)
    , inv(N+1)
    , finv(N+1)
  {}

  /**
   * 前計算を行う.
   * operator()呼び出しの前に必ず実行すること.
   */
  void init() {
    fac[0]  = fac[1]  = com_int(1);
    finv[0] = finv[1] = com_int(1);
    inv[0] = -1;
    inv[1] = com_int(1);

    for (int i = 2; i < (int)fac.size(); ++i) {
      fac[i] = (fac[i - 1] * i) % mMod;
      inv[i] = mMod - (inv[mMod % i] * (mMod / i)) % mMod;
      finv[i] = (finv[i - 1] * inv[i]) % MOD;
    }
  }

  /**
   * 二項係数を計算する
   * @param n
   * @param k
   * @return nCk (mod m)
   */
  com_int operator()(int n, int k) {
    if (n < k) {
      return com_int(0);
    }
    if (n < 0 || k < 0) {
      return com_int(0);
    }
    if (n > mInf) {
      throw std::runtime_error("nが大きすぎる");
    }
    com_int ret{1};
    ret *= fac[n];
    ret %= mMod;
    ret *= finv[k];
    ret %= mMod;
    ret *= finv[n - k];
    ret %= mMod;
    return ret;
  }
  
};

void solve(void)
{
  int N, K; cin >> N >> K;
  vector<ll> A(N);
  for (auto& a : A) {
    cin >> a;
  }
  boost::sort(A, std::less<ll>());

  Combination<> comb(N);
  comb.init();

  ll sumMin{};
  for (int i = 1; i <= N; ++i) {
    auto r = comb(N-i, K-1);
    r *= A[i-1];
    r %= MOD;
    sumMin += r;
  }

  ll sumMax{};
  for (int i = 1; i <= N; ++i) {
    auto r = comb(i-1, K-1);
    r *= A[i-1];
    r %= MOD;
    sumMax += r;
  }

  auto ans = sumMax - sumMin;
  ans %= MOD;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 3456