#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#ifdef ZERO_IQ
ios_base::sync_with_stdio ( false ), cin.tie ( 0 ), cout.tie ( 0 );
#endif

long long const mod = 1e9 + 7;


vector<ll> fact(1e5 + 1), inv(1e5 + 1);

ll fp(ll base, ll exp) {
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n) {
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r) {
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    calcFacAndInv(1e5 + 1);
    sort(v.begin(), v.end());
    ll ans = 0;
    for (int j = 0; j < n; ++j) {
        if (j < m - 1) {
            ans = ((ans % mod) + (((v[j] % mod) * -ncr(n - j - 1, m - 1)) % mod) % mod) % mod;
        } else if (n - j - 1 < m - 1) {
            ans = ((ans % mod) + (((v[j] % mod) * ncr(j, m - 1)) % mod) % mod) % mod;
        } else
            ans = ((ans % mod) + ((((v[j] % mod) * (ncr(j, m - 1) - ncr(n - j - 1, m - 1)) % mod) % mod) % mod)) % mod;
    }
    cout << ans;


    return 0;
}