#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5 + 5;
int n, k;
ll f[N], fat[N];

ll MOD = ll(1e9 + 7);

ll add(ll x, ll y){
    x += y;
    if(x >= MOD) x -= MOD;
    return x;
}

ll sub(ll x, ll y){
    x -= y;
    x += MOD;
    if(x >= MOD) x -= MOD;
    return x;
}

ll mul(ll x, ll y){
    return (x % MOD * y % MOD) % MOD;
}

ll pwr(ll x, ll p){
    if(p == 0) return 1;
    if(p == 1) return x;
    if(p&1) return mul(x, pwr(x, p-1));
    ll t = pwr(x, p/2);
    return mul(t, t);
}

ll inv(ll x){
    return pwr(x, MOD-2);
}

ll nck(int n, int k){
    if(k > n) return 0;
    ll top = fat[n];
    ll down = fat[k];
    ll down2 = fat[n-k];
    top = mul(top, inv(down));
    return mul(top, inv(down2));
}

// f[x] = nck(0, k-2) + nck(1, k-2) + ... + nck(x, k-2)
//
// (a2 - a1) * nck(0, k-2) + (a3 - a1) * nck(1, k-2) + (a4 - a1) * nck(2, k-2) + ... + (an - a1) * nck(n-2, k-2) + 
// (a3 - a2) * nck(0, k-2) + (a4 - a2) * nck(1, k-2) + (a5 - a2) * nck(2, k-2) + ... + (an - a2) * nck(n-3, k-2) +
// (a4 - a3) * nck(0, k-2) + (a5 - a3) * nck(1, k-2) + (a6 - a3) * nck(2, k-2) + ... + (an - a3) * nck(n-3, k-2) +
// ..
// (an - an-1) * nck(0, k-2) + ... + (an - an) * nck(n-n, k-2)
//
// a2 * nck(0, k-2) + a3 * nck(1, k-2) + .. + an * nck(n-2, k-2) - a1 * (nck(0, k-2) + nck(1, k-2) + ... + nck(n-2, k-2))
// a3 * nck(0, k-2) + a4 * nck(1, k-2) + .. + an * nck(n-3, k-2) - a2 * (nck(0, k-2) + nck(1, k-2) + ... + nck(n-3, k-2))
// a4 * nck(0, k-2) + a5 * nck(1, k-2) + .. + an * nck(n-4, k-2) - a3 * (nck(0, k-2) + nck(1, k-2) + ... + nck(n-4, k-2))
//
// a2 * nck(0, k-2) + (a3 * (nck(0, k-2) + nck(1, k-2))) + (a4 * (nck(0, k-2) + nck(1, k-2) + nck(2, k-2))) + ... + (an * (nck(0, k-2) + nck(1, k-2)
// + nck(2, k-2) + ... + nck(n-2, k-2)) - (a1 * f[n-2] + a2 * f[n-3] + a3 * f[n-4] + ... + a_n-2 * f[1])
//
// a2 * f[0] + a3 * f[1] + a4 * f[2] + ... + an * f[n-2] - (a1 * f[n-2] + a2 * f[n-3] + ... + an-2 * f[1])
//
// p todo i de 2 ate n
// a = sum(a_i * f[i-2])
//
// p todo i de 1 até n-2
// b = sum(a_i * f[n-2-(i-1)])
//
// ans = a - b
//
// a2 + a3 + ... + an - a1 * (n-1)
// a3 + a4 + ... + an - a2 * (n-2)
// a4 + a5 + ... + an - a3 * (n-3)
//
// a2 + 2a3 + 3a4 + 4a5 + ... + (n-1)an - (a1 * (n-1) + a2 * (n-2) + ... + an-1 * (n-n+1))
//
// p todo i de 2 ate n
// a = sum((i-1) * a_i)
//
// p todo i de 1 ate n - 1
// b = sum(a_i * (n-i))

void pre(){
    fat[0] = 1;
    for(int i = 1; i < N; i++) fat[i] = mul(i, fat[i-1]);
    for(int i = 0; i < k - 2; i++) f[i] = 0;
    for(int i = k - 2; i < N; i++){
        f[i] = add(f[i-1], nck(i, k-2));
        //printf("i: %d, f[i]: %d\n", i, f[i]);
    }
}

int main(){
    fcin;

    cin >> n >> k;
    pre();

    if(k == 1) return cout << 0, 0;


    ll sum1 = 0, sum2 = 0;
    vector<ll> a(n+1);
    for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a.begin() + 1, a.end());

    if(k == 2){
        ll p = 0;
        for(int i = 2; i <= n; i++) p = add(p, mul(i-1, a[i]));
        ll q = 0;
        for(int i = 1; i <= n-1; i++) q = add(q, mul(a[i], n-i));
        
        cout << sub(p, q) << endl;
        return 0;
    }

    for(int i = 2; i <= n; i++) sum1 = add(sum1, mul(a[i], f[i-2]));
    for(int i = 1; i <= n - 2; i++) sum2 = add(sum2, mul(a[i], f[n-2-(i-1)]));

    ll ans = sub(sum1, sum2);
    cout << ans % MOD << endl;
    return 0;
}



Measured memory_bytes: 2560