#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>

using namespace std;
typedef string::const_iterator State;
const long double Ma_PI = 3.1415926535897932384626433832795028841971L;
#define eps 1e-7
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
typedef struct BigInt {
    string s = "0";
    BigInt operator +(BigInt obj) {
        string c;
        while (max(obj.s.length(), this->s.length()) + 1 > c.length()) {
            c.pb('0');
        }
        for (int q = 0; q < obj.s.length(); ++q) {
            c[c.length() - 1 - q] = obj.s[obj.s.length() - q - 1];
        }
        for (int q = 0; q < this->s.length(); ++q) {
            c[c.length() - 1 - q] += this->s[this->s.length() - 1 - q] - '0';
            if (c[c.length() - 1 - q] > '9') {
                c[c.length() - 2 - q]++;
                c[c.length() - 1 - q] -= 10;
            }
        }
        if (c.front() == '0') {
            c.erase(c.begin());
        }
        return BigInt{ c };
    }
    BigInt operator *(BigInt obj) {
        BigInt ans;
        for (int i = this->s.length() - 1; i >= 0; --i) {
            REP(q, this -> s[i] - '0') {
                ans = ans + obj;
            }
            obj.s.pb('0');
        }
        return ans;
    }
}BigInt;

#define int ll
ll pow(int a, int b) {
    int ans = 1;
    while (b != 0) {
        if (b % 2) {
            ans *= a;
            ans %= MAX_MOD;
        }
        b /= 2;
        a *= a;
        a %= MAX_MOD;
    }
    return ans;
}
ll inv(int now) {
    return pow(now, MAX_MOD - 2LL);
}

ll mae[1000001];
ll gyaku[1000001];
ll combination(int a, int b) {
    ll ans = mae[a];
    ans *= gyaku[b];
    ans %= MAX_MOD;
    ans *= gyaku[a - b];
    ans %= MAX_MOD;
    return ans;
}

ll Minus(int a) {
    return MAX_MOD - (a % MAX_MOD);
}

void solve() {
    mae[0] = 1;
    gyaku[0] = 1;
    REP(i, 1000000) {
        mae[i + 1] = mae[i] * (i + 1LL);
        mae[i + 1] %= MAX_MOD;
        gyaku[i + 1] = inv(mae[i + 1]);
    }
    int n, k;
    cin >> n >> k;
    vector<int> inputs;
    REP(i, n) {
        int a;
        cin >> a;
        inputs.pb(a);
    }
    sort(ALL(inputs));
    ll ans = 0;
    for (int i = 0; i < n - k + 1; ++i) {
        int cost = inputs[i] % MAX_MOD;
        cost *= combination(n - i - 1, k - 1);
        cost %= MAX_MOD;
        cost += 10LL * MAX_MOD;
        cost %= MAX_MOD;
        ans += Minus(cost);
        ans %= MAX_MOD;
    }
    reverse(ALL(inputs));
    for (int i = 0; i < n - k + 1; ++i) {
        int cost = inputs[i] % MAX_MOD;
        cost *= combination(n - i - 1, k - 1);
        cost %= MAX_MOD;
        cost += 10LL * MAX_MOD;
        cost %= MAX_MOD;
        ans += cost;
        ans %= MAX_MOD;
    }
    cout << ans << endl;
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 17016