#include <bits/stdc++.h>

template<uint64_t m = 1000000007>
class ModInt {
public:
    ModInt(const int64_t x): x(x < 0 ? x + m : x) { }

    ModInt operator + (const ModInt y) const {
        return (x + y.x) % m;
    }

    ModInt operator - (const ModInt y) const {
        return x + y.negate();
    }

    ModInt operator * (const ModInt y) const {
        return (x * y.x) % m;
    }

    ModInt operator / (const ModInt y) const {
        return *this * y.inverse();
    }

    void operator += (const ModInt y) {
        *this = *this + y;
    }

    void operator -= (const ModInt y) {
        *this = *this - y;
    }

    void operator *= (const ModInt y) {
        *this = *this * y;
    }

    void operator /= (const ModInt y) {
        *this = *this / y;
    }

    bool operator == (const ModInt y) const {
        return x == y.x;
    }

    uint64_t data() const {
        return x;
    }

    ModInt pow(uint64_t n) const {
        ModInt y = 1;
        ModInt factor = x;

        while(n) {
            if(n & 1) {
                y *= factor;
            }
            factor *= factor;
            n >>= 1;
        }

        return y;
    }

    ModInt inverse() const {
        const auto n = extended_gcd(x, m).first;
        return mod_unsigned(n);
    }

    ModInt negate() const {
        return m - x;
    }

    ModInt factorial() const {
        static auto memo = std::vector<ModInt>(1, 1);
        if(memo.size() > x) {
            return memo[x];
        }

        memo.push_back(ModInt(x - 1).factorial() * x);
        return memo[x];
    }

    static ModInt combination(const uint64_t n, const uint64_t r) {
        if(n <= r) {
            return 1;
        }

        const auto nf = ModInt(n).factorial();
        const auto rf = ModInt(r).factorial();
        const auto nrf = ModInt(n - r).factorial();

        return nf / rf / nrf;
    }

private:
    uint64_t x;

    static std::pair<int64_t, int64_t> extended_gcd(const uint64_t a, const uint64_t b) {
        if(a == 0) {
            return std::make_pair(0, 1);
        }

        const auto p = extended_gcd(b % a, a);

        const auto s = p.first;
        const auto t = p.second;
        const int64_t q = b / a;

        return std::make_pair(t - s * q, s);
    }

    static uint64_t mod_unsigned(const int64_t n) {
        if(n >= 0) {
            return n;
        }

        const auto y = (-n) / m + 1;
        return n + m * y;
    }
};

template<class T>
std::vector<T> read_vector(const uint64_t n) {
    auto v = std::vector<T>();
    v.reserve(n);

    for(uint64_t i = 0; i < n; ++i) {
        T t;
        std::cin >> t;
        v.push_back(t);
    }

    return v;
}

int main() {
    int n, k;
    std::cin >> n >> k;

    auto as = read_vector<int64_t>(n);

    std::sort(as.begin(), as.end());

    ModInt<> answer = 0;

    for(int i = 0; i <= n - k; ++i) {
        const ModInt<> a = as[i];
        answer += ModInt<>::combination(n - i - 1, k - 1) * a.negate();
    }

    for(int i = n - 1; i >= k - 1; --i) {
        const ModInt<> a = as[i];
        answer += ModInt<>::combination(i, k - 1) * a;
    }

    std::cout << answer.data() << std::endl;

    return 0;
}


Measured memory_bytes: 4984