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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

// ax+by=1の解
int extgcd(int a, int b, int& x, int& y){
    int d = a;
    if (b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a / b)*x;
    }
    else{
        x = 1; y = 0;
    }
    return d;
}

// mod mでのaの逆数
int mod_inverse(int a, int m){
    int x, y;
    extgcd(a, m, x, y);
    return (m + x%m) % m;
}

const int MAX = 123456;

// 階乗の事前計算
int fac[MAX], fac_inv[MAX];

void make_table(int N){
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= N; i++) fac[i] = (fac[i - 1] * i) % mod;
    for(int i=0; i<=N; i++) fac_inv[i] = mod_inverse(fac[i], mod);
}

int combination(int n, int r, int p){
    if(n<0 || r<0 || r>n) return 0;
    return (fac[n] * fac_inv[r]) % p * fac_inv[n-r] % p;
}
signed main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(), A.end());
    make_table(MAX-1);
    int ans1 = 0, ans2=0;;
    rep(i, N){
        ans1 += (A[i] * combination(i, K-1, mod))%mod;
        cerr << A[i] << " "<<combination(i, K-1, mod) << endl;
        ans1%=mod;
    }
    cerr << ans1 << endl;
    rep(i, N){
        ans2 += (A[i] * combination(N-(i+1), K-1, mod))%mod;
        ans2%=mod;
    }
    cerr << ans2 << endl;
    cout << (ans1 + mod - ans2) % mod << endl;
    
    return 0;
}


Measured memory_bytes: 2944