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

using int64 = long long;

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;
    }
};

#define MAX 114514

std::vector<int64> fact(MAX + 1);

int64 extgcd(int64 a, int64 b, int64& x, int64& y)
{
    int64 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(int64 n, int64 p, int64& e)
{
    e = 0;
    if (n == 0)
        return 1;

    int64 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;
}

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

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

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

void init(int64 M)
{
    fact[0] = 1;
    for(int64 i = 0; i < MAX; i++){
        fact[i + 1] = fact[i] * (i + 1) % M;
    }
}

int main()
{
    int64 N, K;
    constexpr int64 M = 1e9 + 7;
    init(M);
    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<M> min_sum;
    ModInt<M> max_sum;
    for (int64 i = 0; i < N; i++) {
        int64 w = mod_comb(N - 1 - i, K - 1, M);
        min_sum -= ModInt<M>(A[i] * w);
        max_sum += ModInt<M>(A[N - 1 - i] * w);
    }
    std::cout << (max_sum += min_sum).value() << std::endl;
    return 0;
}

Measured memory_bytes: 1920