#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;

long long constexpr mod = 1000000007LL;

class llm{
    long long l;
    static std::unordered_map<long long, llm> inv;

  public:
    llm(long long m = 0LL) : l((m % mod >= 0)?(m % mod):(m % mod + mod)) {};

    llm inverse() const {
        if(inv.find(l) == inv.end()){
            llm x = pow(mod - 2);
            inv.emplace(l, x);
            return x;
        }
        return inv[l];
    }

    llm pow(long long i) const {
        if (i < 0)  return inverse().pow(i);
        return pow(l, i, 1);
    }

    static llm pow (long long a, long long i, long long base = 1) {
        if (i == 0) return base;
        return pow( a * a % mod, i >> 1, base * ((i & 1) == 0 ? 1 : a) % mod);
    }

    llm operator= (llm m) {l = m.l; return *this;}

    llm operator<< (long long i) const {return pow( i);};
    llm operator>> (long long i) const {return pow(-i);}

    llm operator+ (llm m)       const {return llm(l + m.l);}
    llm operator+ (int m)       const {return llm(l + (m % mod));}
    llm operator+ (long m)      const {return llm(l + (m % mod));}
    llm operator+ (long long m) const {return llm(l + (m % mod));}

    llm operator- (llm m)       const {return llm(l - m.l);}
    llm operator- (int m)       const {return llm(l - (m % mod));}
    llm operator- (long m)      const {return llm(l - (m % mod));}
    llm operator- (long long m) const {return llm(l - (m % mod));}

    llm operator* (llm m)       const {return llm(l * m.l);}
    llm operator* (int m)       const {return llm(l * (m % mod));}
    llm operator* (long m)      const {return llm(l * (m % mod));}
    llm operator* (long long m) const {return llm(l * (m % mod));}

    llm operator/ (llm m)       const {return llm((*this) * m.inverse() % mod);}
    llm operator/ (int m)       const {return llm(l * llm(m).inverse()) % mod;}
    llm operator/ (long m)      const {return llm(l * llm(m).inverse()) % mod;}
    llm operator/ (long long m) const {return llm(l * llm(m).inverse()) % mod;}

    long long operator++ (void) {return l = (l + 1) % mod;}
    long long operator++ (int)  {long long tmp = l; ++(*this); return tmp;}

    long long operator-- (void) {return l = (l - 1) % mod;}
    long long operator-- (int)  {long long tmp = l; --(*this); return tmp;}

    llm operator+ (void) const {return llm( l);}
    llm operator- (void) const {return llm(-l);}

    template<typename T> llm operator+= (T m) {return *this = *this + m;}
    template<typename T> llm operator-= (T m) {return *this = *this - m;}
    template<typename T> llm operator*= (T m) {return *this = *this * m;}
    template<typename T> llm operator/= (T m) {return *this = *this / m;}

    operator long long() {return l;}

    friend std::istream &operator>>(std::istream &stream, llm &m);

};

std::unordered_map<long long, llm> llm::inv;

std::istream& operator>> (std::istream &stream, llm &m) {
    long long tmp;
    stream >> tmp;
    m.l = tmp % mod;
    return stream;
}


// struct cc{
//     ll buff[10000][10000];

//     constexpr int combination(int n, int r){
//         if (!buff[n][r]) {
//             return buff[n][r];
//         }
//     if (n == 0 || r == 0 || n == r) return 1;
//     return combination(n - 1, r - 1) + combination(n - 1, r);
// }


//     constexpr cc() : buff(){
//         for0(i, 100000){
//             forx(j, i, 0){
//                 buff[i][j] = combination(i, j);
//             }
//         }
//     }
// };

// constexpr ll fact(ll n, ll i = 1){
//     return n == 0 ? i : fact(n - 1, i * n % mod);
// }

// template<ll ...vals>
// constexpr array<ll, sizeof...(vals)> generateArray(integer_sequence<ll, vals...>){
//     return {{fact(vals)...}};
// }

// template<size_t N>
// struct factTable{
//     constexpr static array<ll, N> table
//     = generateArray(std::make_integer_sequence<ll, N>{});
//     constexpr static ll get(size_t i) {
//         return table[i];
//     }
// };

// template<size_t N>
// constexpr array<int, N> factTable<N>::table;

// using fac = factTable<100000>;

// int combination(llm n, llm r){
//     return fac::get(ll(n));
// }

llm combination(llm n, llm r, vector<llm> const &fact){
    return fact[n] / (fact[n - r] * fact[r]);
}

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

    int n, k;

    cin >> n >> k;

    vector<llm> a(n);

    for0(i, n){
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    if (k == 1) {
        cout << 0;
        return 0;
    }

    vector<llm> fact(n + 1);
    fact[0] = 1;
    for1n(i, n){
        fact[i] = fact[i - 1] * i;
    }

    llm result = 0;

    for0(i, n){
        if (n - i - 1 >= k - 1) {
            result -= combination(n - i - 1, k - 1, fact) * a[i];
        }
    }


    for0(i, n){
        if(i >= k - 1){
            result += combination(i, k - 1, fact) * a[i];
        }
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 3852