#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}

using vi = vector<int>;

#define P (1'000'000'007)

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

template<int MOD=P>
struct Mod {
public:
    long long signed value;

    Mod(long long signed val): value(val % MOD) {
        if (value < 0) value += MOD;
    }

    constexpr Mod& operator+=(const Mod& other) noexcept { 
        value += other.value;
        value %= MOD;
        return *this;
    }
    constexpr Mod& operator-=(const Mod& other) noexcept {
        value -= other.value;
        if (value < 0) value += MOD;
        return *this;
    }
    constexpr Mod& operator*=(const Mod& other) noexcept {
        value *= other.value;
        value %= MOD;
        return *this;
    }

    constexpr Mod operator-() noexcept {
         return value == 0 ? 0 : MOD - value;
    }

    constexpr Mod operator+(const Mod& other) const noexcept { return Mod(*this) += other; }
    constexpr Mod operator-(const Mod& other) const noexcept { return Mod(*this) -= other; }
    constexpr Mod operator*(const Mod& other) const noexcept { return Mod(*this) *= other; }
    constexpr bool operator==(const Mod& other) const noexcept { return this->value == other.value; }
    constexpr bool operator!=(const Mod& other) const noexcept { return this->value != other.value; }
};

inline int fast_pow(int x, int n, int mod) {
    long long signed res = 1;
    long long accumulation = x;
    for (int i = 0; n >> i > 0; ++ i) {
        if ((n >> i) % 2) {
            res *= accumulation;
            res %= mod;
        }
        accumulation *= accumulation;
        accumulation %= mod;
    }

    return res;
}

template<int MOD=P>
class Combination {
public:
    Combination(int n) {
        long long signed accumulation = 1;
        factorials.push_back(1);
        for (int i = 1; i <= n; ++ i) {
            accumulation *= i;
            accumulation %= MOD;
            factorials.push_back(accumulation);
        }

        int n_inv = fast_pow(factorials[n], MOD - 2, MOD);
        invs.push_back(n_inv);
        accumulation = n_inv;
        for (int i = n; i >= 2; --i) {
            accumulation *= i;
            accumulation %= MOD;
            invs.push_front(accumulation);
        }
        invs.push_front(1);
    }

    int comb(int n, int r) {
        if (r == 0) return 1;
        long long signed res = 1ll * factorials[n] * invs[r] % MOD;
        return 1ll * res * invs[n - r] % MOD;
    }

    int perm(int n, int r) {
        long long signed res = 1ll * factorials[n] * invs[n - r] % MOD;
        return res;
    }

    std::deque<int> factorials;
    std::deque<int> invs;
};

signed main() {
    int n, k;
    cin >> n >> k;

    vi va;
    rep(i, n) {
        capi(a);
        va.push_back(a);
    }

    sort(all(va));

    Combination comb(n);

    Mod ans(0);
    if (k > 1) {
        for (int i = k - 1; i < n; ++i) {
            ans += va[i] * comb.comb(i, k - 1);
        }
        for (int i = 0; i < n - k + 1; ++i) {
            ans -= va[i] * comb.comb(n - i - 1, k - 1);
        }
    }

    cout << ans.value;

    return 0;
}


Measured memory_bytes: 5104