// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <algorithm>



using ll = long long;

#define MAX 114514



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



ll extgcd(ll a, ll b, ll& x, ll& y)

{

    ll d = a;

    if (b != 0) {

        d = extgcd(b, a % b, y, x);

        y -= (a / b) * x;

    }

    else {

        x = 1; y = 0;

    }

    return d;

}



ll mod_inverse(ll a, ll m)

{

    ll x, y;

    extgcd(a, m, x, y);

    return (m + x % m) % m;

}



ll mod_fact(ll n, ll p, ll& e)

{

    e = 0;

    if (n == 0)

        return 1;



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

}



ll mod_comb(ll n, ll k, ll p)

{

    if (n < 0 || k < 0 || n < k)

        return 0;



    ll e1, e2, e3;

    ll 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(ll M)

{

    fact[0] = 1;

    for(ll i = 0; i < MAX; i++){

        fact[i + 1] = fact[i] * (i + 1) % M;

    }

}



ll mod(ll x, ll M)

{

    if (x < 0)

        x += M;



    return x % M;

}



int main()

{

    ll N, K;

    constexpr ll M = 1e9 + 7;

    init(M);

    std::cin >> N >> K;

    std::vector<ll> A(N);

    for (ll i = 0; i < N; i++) {

        std::cin >> A[i];

    }

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

    ll min_sum = 0;

    ll max_sum = 0;

    for (ll i = 0; i < N; i++) {

        ll w = mod_comb(N - 1 - i, K - 1, M);

        min_sum = mod(min_sum - mod(A[i] * w, M), M);

        max_sum = mod(max_sum + mod(A[N - 1 - i] * w, M), M);

    }

    std::cout << mod(max_sum + min_sum, M) << std::endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <algorithm>



using int64 = long long;

constexpr int64 M = 1e9 + 7;



template<int64 MOD>

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<M> min_sum;

    ModInt<M> max_sum;

    ModCombination<M> c(N);

    for (int64 i = 0; i < N; i++) {

        int64 w = c.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;

}


// Fastest known solution for this problem: