#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

const ll MOD = ll(1e9) + 7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll i, ll mod){
    return modpow(i, mod-2, mod);
}

ll comb(ll n, ll a, ll mod) {
    ll ans = 1, denom = 1;
    rep(i,a) {
        ans = ans * (n - i) % mod;
        denom = denom * (i+1) % mod;
    }
    ans = ans * modinv(denom, mod) % mod;
    return ans;

}

struct combination {
    vector<ll> fact, ifact;
    combination(int n): fact(n+1), ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for(int i=1; i<=n; i++) {
            fact[i] = (fact[i-1] * i) % MOD;
        }
        for(int i=0; i<=n; i++) {
            ifact[i] = modinv(fact[i], MOD);
        }
    }
    ll operator()(int n, int k) {
        if (k<0 || k>n) return 0;
        return (((fact[n]*ifact[k]) % MOD) * ifact[n-k]) % MOD;
    }
};

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    if (K == 1) {
        cout << 0 << "\n";
        return 0;
    }
    ssort(A);
    combination c(N+1);
    ll sMX = 0, sMI = 0;
    repSE(i,K-1,N) {
        ll add = A[i] * c(i, K-1) % MOD;
        sMX = (sMX + add) % MOD;
    }
    rep(i,N-K+1) {
        ll add = A[i] * c(N-i-1, K-1) % MOD;
        sMI = (sMI + add) % MOD;
    }
    ll ans = (sMX - sMI) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2176