#include <bits/stdc++.h>

using namespace std;

namespace modint {
    template <std::uint_fast64_t Modulus> class modint {
        using u64 = std::uint_fast64_t;
        u64 a;

        public:

        template <class INT>
        constexpr modint(const INT x = 0) noexcept : a(x >= 0 ? x % Modulus : x + Modulus) {}
        constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
        constexpr u64 &value() noexcept { return a; }
        constexpr const u64 &value() const noexcept { return a; }
        constexpr modint operator+(const modint rhs) const noexcept {
            return modint(*this) += rhs;
        }
        constexpr modint operator-(const modint rhs) const noexcept {
            return modint(*this) -= rhs;
        }
        constexpr modint operator*(const modint rhs) const noexcept {
            return modint(*this) *= rhs;
        }
        constexpr modint operator/(const modint rhs) const noexcept {
            return modint(*this) /= rhs;
        }
        constexpr modint &operator+=(const modint rhs) noexcept {
            a += rhs.a;
            if (a >= Modulus) {
                a -= Modulus;
            }
            return *this;
        }
        constexpr modint &operator-=(const modint rhs) noexcept {
            if (a < rhs.a) {
                a += Modulus;
            }
            a -= rhs.a;
            return *this;
        }
        constexpr modint &operator*=(const modint rhs) noexcept {
            a = a * rhs.a % Modulus;
            return *this;
        }
        constexpr modint &operator/=(modint rhs) noexcept {
            u64 exp = Modulus - 2;
            while (exp) {
                if (exp % 2) {
                    *this *= rhs;
                }
            rhs *= rhs;
            exp /= 2;
            }
            return *this;
        }

        constexpr bool operator<(const modint& rhs) noexcept {return this.a < rhs.a;}
        constexpr bool operator>(const modint& rhs) noexcept {return rhs < this;}
        constexpr bool operator<=(const modint& rhs) noexcept {return !(this > rhs);}
        constexpr bool operator>=(const modint& rhs) noexcept {return !(this < rhs);}

        constexpr bool operator==(const modint& rhs) noexcept {return this.a == rhs.a;}
        constexpr bool operator!=(const modint& rhs) noexcept {return !(this == rhs);}

        constexpr modint& operator++() noexcept {
            this += 1;
            return *this;
        }

        constexpr modint operator++(int) noexcept {
            modint tmp(*this);
            this++;
            return tmp;
        }

        constexpr modint operator-() noexcept {
            return modint(0) - this;
        }

        template <std::uint_fast64_t M>
        friend constexpr std::ostream& operator<<(std::ostream& os, const modint<M>& rhs) noexcept {
            os << rhs.a;
            return os;
        }
        template <std::uint_fast64_t M>
        friend constexpr std::istream& operator>>(std::istream& is, modint<M>& rhs) noexcept {
            is >> rhs.a;
            return is;
        }
    };

    template <class INT>
    INT pow(INT n, INT k){
        if (k == 0)
            return 1;
        if (k % 2 == 0){
            INT res = pow(n, k / 2);
            return res * res;
        }
        return pow(n, k - 1) * n;
    }
}

template<class Modint>
class Comb{
    vector<Modint> fact(uint64_t n){
        vector<Modint> f(n + 1);
        f[0] = 1;
        for (uint64_t i = 0; i < n; i++)
            f[i + 1] = Modint(i + 1) * f[i];
        return f;
    }

    vector<Modint> invfact(uint64_t n){
        vector<Modint> inv(n + 1);
        inv[n] = Modint(1) / f[n];
        for (uint64_t i = n; i > 0; i--)
            inv[i - 1] = inv[i] * i;
        return inv;
    }

public:
    vector<Modint> f, invf;

    Comb(uint64_t n){
        f = fact(n);
        invf = invfact(n);
    }

    Modint comb(int64_t a, int64_t b){
        if (a < b)
            return 0;
        if (a < 0 or b < 0)
            return 0;
        return f[a] * invf[b] * invf[a - b];
    }
};

int main(){
    const constexpr int64_t p = 1e9 + 7;
    using mint = modint::modint<p>;
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());
    sort(A.begin(), A.end());

    Comb<mint> c(n);
    mint ans = 0;
    for (int i = 0; i < n; i++){
        auto coef = c.comb(i, k - 1) - c.comb(n - i - 1, k - 1);
        ans += mint(A[i]) * coef;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560