#include <iostream>
#include <vector>
#include <algorithm>

using int64 = long long;
constexpr int64 MOD = 1e9 + 7;

class ModCombination {
private:
    std::vector<int64> fact;

    void init(int max)
    {
        fact.resize(max + 1);
        fact[0] = 1;
        for (int i = 0; i < max; i++)
            fact[i + 1] = fact[i] * (i + 1) % MOD;
     }

    int64 extgcd(int64 a, int64 b, int64 &x, int64 &y)
    {
        int d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        }
        else
            x = 1, y = 0;

        return d;
    }

    int64 mod_inverse(int64 a, int64 m)
    {
        int64 x, y;
        extgcd(a, m, x, y);
        return (m + x % m) % m;
    }

    int64 mod_fact(int n, int64 p, int64 &e)
    {
        e = 0;
        if (n == 0)
            return 1;

        int res = mod_fact(n / p, p, e);
        e += n / p;
        if (n / p % 2 != 0)
            return res * (p - fact[n % p]) % p;

        return res * fact[n % p] % p;
    }

public:
    ModCombination(int max)
    {
        init(max);
    }

    int64 mod_comb(int n, int k, int64 p)
    {
        if (n < 0 || k < 0 || n < k)
            return 0;

        int64 e1, e2, e3;
        int64 a1 = mod_fact(n, p, e1);
        int64 a2 = mod_fact(k, p, e2);
        int64 a3 = mod_fact(n - k, p, e3);
        if (e1 > e2 + e3)
            return 0;

        return a1 * mod_inverse(a2 * a3 % p, p) % p;
    }
};

template <int64 MOD>
class ModInt {
private:
    int64 v;

    int64 mod_of(int64 x)
    {
        if (x < 0)
            x += MOD;

        return x % MOD;
    }

    int64 mod_pow(int64 x, int64 n)
    {
        if (n == 0)
            return 1;

        int64 res = mod_pow(x * x % MOD, n / 2);
        if (n & 1)
            res = res * x % MOD;

        return res;
    }

public:
    ModInt(int64 x = 0) : v(mod_of(x)) {}

    ModInt operator + (const ModInt &rhs) const
    {
        return ModInt(v + rhs.v);
    }
    ModInt operator - (const ModInt &rhs) const
    {
        return ModInt(v - rhs.v);
    }
    ModInt operator * (const ModInt &rhs) const
    {
        return ModInt(v * rhs.v);
    }
    ModInt operator / (const ModInt &rhs) const
    {
        return ModInt(v * mod_pow(rhs.v, MOD - 2));
    }
    ModInt operator += (const ModInt &rhs)
    {
        v = mod_of(v + rhs.v);
        return *this;
    }
    ModInt operator -= (const ModInt &rhs)
    {
        v = mod_of(v - rhs.v);
        return *this;
    }
    ModInt operator *= (const ModInt &rhs)
    {
        v = mod_of(v * rhs.v);
        return *this;
    }
    ModInt operator /= (const ModInt &rhs)
    {
        v = mod_of(v * mod_pow(rhs.v, MOD - 2));
        return *this;
    }
    ModInt operator - () const
    {
        return ModInt(-v);
    }
    bool operator == (const ModInt &rhs) const
    {
        return v == rhs.v;
    }
    bool operator != (const ModInt &rhs) const
    {
        return v != rhs.v;
    }
    int64 value()
    {
        return v;
    }
};

int main()
{
    int64 N, K;
    std::cin >> N >> K;
    std::vector<int64> A(N);
    for (int64 i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    std::sort(A.begin(), A.end());
    ModInt<MOD> min_sum;
    ModInt<MOD> max_sum;
    ModCombination c(N);
    for (int64 i = 0; i < N; i++) {
        int64 w = c.mod_comb(N - 1 - i, K - 1, MOD);
        min_sum -= ModInt<MOD>(A[i] * w);
        max_sum += ModInt<MOD>(A[N - 1 - i] * w);
    }
    std::cout << (max_sum += min_sum).value() << std::endl;
    return 0;
}


Measured memory_bytes: 1792