#include <iostream>
#include <algorithm>

using namespace std;

const int Z = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);

    int inv[n+1];
    for (int i = 1; i <= n; i++) {
        inv[i] = i == 1 ? 1 : 1ll * (Z - Z / i) * inv[Z%i] % Z;
    }

    int fac[n+1], ifac[n+1];
    for (int i = 0; i <= n; i++) {
        fac[i] = i == 0 ? 1 : 1ll * fac[i-1] * i % Z;
        ifac[i] = i == 0 ? 1 : 1ll * ifac[i-1] * inv[i] % Z;
    }

    int ans = 0;
    for (int i = 0; i <= n - k; i++) {
        ans = ((ans - 1ll * fac[n-i-1] * ifac[k-1] % Z * ifac[n-i-k] % Z * a[i]) % Z + Z) % Z;
    }
    for (int i = k - 1; i < n; i++) {
        ans = ((ans + 1ll * fac[i] * ifac[k-1] % Z * ifac[i+1-k] % Z * a[i]) % Z + Z) % Z;
    }

    cout << ans << endl;

    return 0;
}
