#include <bits/stdc++.h>
#include <boost/operators.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){ 
    cin.tie(nullptr); ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}


template<u_int32_t P>
struct IntMod : boost::totally_ordered<IntMod<P>, boost::integer_arithmetic<IntMod<P>>> {
    int64_t value;
    IntMod(const int64_t& value) : value(value < 0 ? value % P + value : value % P) {}
    bool operator==(const IntMod<P>& other) const { return value == other.value; }
    bool operator<(const IntMod<P>& other) const { return value < other.value; }
    IntMod<P>& operator+=(const IntMod<P>& other) {
        value = (value + other.value) % P;
        return *this;
    }
    IntMod<P>& operator-=(const IntMod<P>& other) {
        value = (value - other.value) % P;
        if (value < 0) {
            value += P;
        }
        return *this;
    }
    IntMod<P>& operator*=(const IntMod<P>& other) {
        value = (value * other.value) % P;
        return *this;
    }
    IntMod<P>& operator/=(const IntMod<P>& other) {
        value = (value * other.inverse().value) % P;
        return *this;
    }
    IntMod<P> inverse() const {
        int64_t a = value, b = P, u = 1, v = 0;
        while (b) {
            int64_t t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= P;
        if (u < 0) {
            u += P;
        }
        return u;
    }
    IntMod<P> pow(u_int32_t n) const {
        IntMod<P> res = 1, a = value;
        while (n > 0) {
            if (n & 1) {
                res *= a;
            }
            a *= a;
            n >>= 1;
        }
        return res;
    }
    IntMod<P> combination(u_int32_t k) const {
        IntMod<P> nf = 1, kf = 1;
        for (int64_t n = value; k > 0; n--, k--) {
            nf *= n;
            kf *= k;
        }
        nf *= kf.inverse();
        return nf;
    }
};
template<u_int32_t P>
ostream& operator<<(ostream& out, const IntMod<P>& m) {
    out << m.value;
    return out;
}

using MInt = IntMod<1000000007>;

int main() {
    int N, K;
    cin >> N >> K;
    auto A = scan<vector<ll>>(N);
    sort(A);
    MInt comb = 0;
    ll dsum = 0;
    MInt ans = 0;
    for (auto i : irange(0, N - 1)) {
        if (i == K - 2) {
            comb = 1;
        } else if (i > K - 2) {
            comb = comb * i / (i - (K - 2));
        }
        dsum += A[N - 1 - i];
        dsum -= A[i];
        if (i >= K - 2) {
            ans += comb * dsum;
        }
        dump(i, comb, dsum, ans, A[N - 1 - i], A[i]);
    }
    cout << ans << LN;
}


Measured memory_bytes: 1660