#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

template <typename T>
inline bool chmin(T& a, T b){
    if(b < a){ a = b; return true;}
    return false;
}

template <typename T>
inline bool chmax(T& a, T b){
    if(a < b){ a = b; return true;}
    return false;
}

inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

template <std::size_t N, const int mod>
class CombinationMod{
public:
    long long int Power[N + 1];      // Power[n] := n!
    long long int powInverse[N + 1]; // powInverse[n] := 1/n!
    long long int Inverse[N + 1];    // Inverse[n] := 1/n
    constexpr CombinationMod(void):Power(), powInverse(), Inverse(){
        Power[0] = 1; Inverse[0] = 1; powInverse[0] = 1;
        for(int x = 1; x <= N; ++x) Power[x] = (Power[x-1] * x) % mod;
        powInverse[N] = inverse(Power[N]);
        for(int x = N; x - 1 >= 0; --x){
            powInverse[x-1] = (powInverse[x] * x) % mod;
            Inverse[x] = (Power[x - 1] * powInverse[x]) % mod;
        }
    }
    // 逆元を求める関数
    constexpr long long int inverse(long long int a) const noexcept {
        long long int b = mod, u = 1, v = 0;
        while (b != 0) { 
            long long int t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= mod; if (u < 0) u += mod;
        return u;
    }
    constexpr void swap(long long int& a, long long int& b) const {
        long long int tmp = a; a = b; b = tmp;
    }
    // nCkを求める関数 : n < k の入力に注意せよ
    inline long long int combination(int n, int k) const noexcept{
        if(n < k or k < 0) return 0;
        return ((Power[n] * powInverse[k] % mod) * powInverse[n-k]) % mod;
    }
    // nHk = n+k-1Ck | n種類のものから重複を許して k個 選ぶ場合の組み合わせ(パターン)
    // ※ n + k - 1 ≤ N でいけないことに注意
    inline long long int repeatedCombination(int n, int k) const noexcept {
        return combination(n + k - 1, k);
    }
};

constexpr int N = 3e5 + 1;
constexpr int mod = 1e9 + 7;
constexpr CombinationMod<N, mod> Cmb;
std::array<lli, N + 1> S;

std::vector<int> A;

int main(void){
    int n, k; scanf("%d%d", &n, &k);
    A.resize(n); REP(i, n) scanf("%d", &A[i]);
    std::sort(A.begin(), A.end());
    if(k == 1){puts("0"); return 0;}
    S[0] = Cmb.combination(0, k-2); for(int x = 1; x <= n; ++x) S[x] = (S[x-1] + Cmb.combination(x, k - 2)) % mod; 
    lli res = 0;
    REP(i, n){
        lli K1 = 0, K2 = 0;
        if(i - 1 >= k - 2) K1 = S[i - 1];
        if(n - 2 - i >= k - 2) K2 = S[n - i - 2];
        lli base = (K1 - K2 + mod) % mod;
        (res += base * A[i]) %= mod;
        if(res < 0) res += mod;
    }
    printf("%lld\n", res);
    




    return 0;
}

Measured memory_bytes: 1408