#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>;

// グリッド上の縦横移動
constexpr std::array<std::pair<int, int>, 4> dxdy = {
    std::pair<int, int>( 1,  0),
    std::pair<int, int>(-1,  0),
    std::pair<int, int>( 0,  1),
    std::pair<int, int>( 0, -1)
};

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 <unsigned int modulus> struct modint{
    int val; // 値本体

    // コンストラクタ
    constexpr modint():val(0){}
    template <class T> constexpr modint(T v){
        val = v % (int)(modulus); 
        if(val < 0) val += modulus;
    }
    constexpr modint& operator+= (const modint<modulus> other) noexcept {
        val += other.val; if(val >= modulus) val -= modulus;
        return *this;
    }
    constexpr modint& operator -= (const modint<modulus> other) noexcept {
        val -= other.val; if(val < 0) val += modulus;
        return *this;
    }
    constexpr modint& operator *= (const modint<modulus> other) noexcept {
        val = (unsigned long long int)(val) * other.val % modulus;
        return *this; 
    }
    constexpr modint& operator /= (const modint<modulus> other) noexcept {
        val = (unsigned long long int)(val) * other.inverse() % modulus;
        return *this;
    }
    constexpr modint operator +(const modint<modulus> v)const noexcept{
        return modint<modulus>(*this) += v;
    }
    constexpr modint operator -(const modint<modulus> v)const noexcept{
        return modint<modulus>(*this) -= v;
    }
    constexpr modint operator *(const modint<modulus> v)const noexcept{
        return modint<modulus>(*this) *= v;
    }
    constexpr modint operator /(const modint<modulus> v)const noexcept{
        return modint<modulus>(*this) /= v;
    }
    constexpr modint& operator ++(void) noexcept {
        if(++val == modulus) val = 0;
        return *this;
    }
    constexpr modint& operator --(void) noexcept {
        if(val-- == 0) val = modulus - 1;
        return *this;
    }
    constexpr modint operator -()const noexcept{
        return modint<modulus>((val == 0 ? 0 : modulus - val));
    }

    // aの逆元を求める関数
    constexpr unsigned int inverse(unsigned int a) const noexcept {
        unsigned int b = modulus;
                 int u = 1,   v = 0;
        while (b != 0) {
            unsigned int t = a / b; 
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        if(u < 0) u += modulus;
        return u;
    }
    constexpr unsigned int inverse(void) const noexcept {return inverse(val);}
    // a^nを返す関数 : nは負の数でも可
    constexpr unsigned int power(unsigned long long int a, long long int n)const noexcept{
        if(n == 0) return 1;
        unsigned long long res = 1, waiting = a;
        if(n < 0) waiting = inverse(), n = -n;
        while(n != 0){ 
            if((n & 1UL) != 0){ res *= waiting; res %= modulus; }
            waiting *= waiting; waiting %= modulus; 
            n /= 2;
        }
        return res;
    }
    constexpr unsigned int power(long long int n) const noexcept {return power(val, n);}
};

template <std::size_t N, unsigned int modulus>
struct combinationMod{
public:
    modint<modulus> Power[N + 1];
    modint<modulus> powInverse[N + 1];
    modint<modulus> inverse[N + 1];
//public:
    constexpr combinationMod(void): Power(), powInverse(), inverse(){
        Power[0] = 1;
        int x = 0; modint<modulus> mx;
        for(x = 1, mx = 1; x <= N; ++x, ++mx) Power[x] = Power[x - 1] * mx;
        powInverse[N] = Power[N].inverse();
        for(x = N, mx = N; x > 0; --x, --mx){
            powInverse[x - 1] = powInverse[x] * mx;
            inverse[x] = powInverse[x] * Power[x - 1];
        }
        inverse[0] = 1;
    }
    constexpr modint<modulus> combination(int n, int k){
        if(k < 0 or n < k) return modint<modulus>();
        return Power[n] * powInverse[k] * powInverse[n - k];
    }
};


constexpr int mod = 1e9 + 7;
constexpr int N = 1e5;
using mint = modint<mod>;
combinationMod<N, mod> Cmb;
std::vector<int> A;

int main(void){
    int n, k; scanf("%d%d", &n, &k);
    if(k == 1){ puts("0"); return 0;}
    A.resize(n); REP(i, n) scanf("%d", &A[i]);
    std::sort(A.begin(), A.end());
    mint MX, mn; mint S;
    for(int i = k - 2; i < n; ++i){
        MX += S * mint(A[i]);
        S += Cmb.combination(i, k - 2);
    }
    S = 0;
    for(int i = n - k; i >= 0; --i){
        S += Cmb.combination(n - i - 2, k - 2);
        mn += S * mint(A[i]);
    }
    MX -= mn;
    printf("%u\n", MX.val);


    


    return 0;
}

Measured memory_bytes: 1792