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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slow
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

struct mint {
  ll x;

  mint(ll _x=0) :
    x(_x >= 0 ? _x%MOD : (MOD - (-_x) % MOD) % MOD)
    {}

  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) const {
    mint ret(*this);
    return ret+=a;
  }

  mint operator-=(const mint a) const {
    mint ret(*this);
    return ret-=a;
  }

  mint operator*=(const mint a) const {
    mint ret(*this);
    return ret*=a;
  }

  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }

  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }

  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret/=a;
  }

  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const {
    // MOD should be a prime
    return pow(MOD-2);
  }

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

  bool operator==(const mint& other) const {
    return x == other.x;
  }

  bool operator!=(const mint& other) const {
    return x != other.x;
  }

  friend ostream& operator<<(ostream& os, const mint& a) {
      return os << a.x;
  }

  friend istream &operator>>(istream &is, mint& a) {
    ll t;
    is >> t;
    a = mint(t);
    return (is);
  }
};


// Calculate aCb mod 1000000007 in O(SIZE)
template<int SIZE>
struct Combination {
  static constexpr long long mod = MOD;

  long long inv[SIZE+1];           // modでの逆元
  long long factorial[SIZE+1];     // modでの階乗
  long long invfactorial[SIZE+1];  // modでの階乗の逆元

  Combination() {
    inv[1] = 1;
    // po()を使えばO(N log p)だが、O(N)で計算するアルゴリズム
    for (int i=2; i<=SIZE; i++) {
      inv[i] = mod - (mod/i)*inv[mod%i] % mod;
    }

    factorial[0] = invfactorial[0] = 1;
    for (int i=1; i<=SIZE; i++){
      factorial[i] = factorial[i-1] * i % mod;
      invfactorial[i] = invfactorial[i-1] * inv[i] % mod;
    }
  }

  long long operator()(long long a, long long b) const {
    if (b<0 || a<b) return 0;

    return (invfactorial[b] * invfactorial[a-b]) % mod * factorial[a] % mod;
  }
};

// ========== end of template ==========
constexpr int N_MAX=1e5;
Combination<N_MAX+100> combi;
int N;
int K;
vll A;

int main(int argc, char** argv) {
  cin >> N >> K;
  A.resize(N);
  for (auto& a : A) {
    cin >> a;
  }
  Sort(A);

  if (K==1) {
    cout << 0 << endl;
    return 0;
  }

  // 1) max(X)
  mint ret = 0;
  REP(i, N) {
    ret += mint(A[i]) * mint(combi(i, K-1));
  }
  // 2) min
  REP(i, N) {
    ret -= mint(A[i]) * mint(combi(N-1-i, K-1));
  }

  cout << ret << endl;
  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 3328