#include <bits/stdc++.h>
using namespace std;
using cpx = complex<double>;
using namespace std::literals;
using Int = long long;
using Double = long double;
#ifdef __GNUG__
#define _GLIBCXX_DEBUG
#endif
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define PUTS(x) cout << (x) << endl;
#define perm(c)                   \
    sort((c).begin(), (c).end()); \
    for (bool c##p = 1; c##p; c##p = next_permutation((c).begin(), (c).end()))
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}
template <typename T>
void Puts(T x) {
    cout << x << endl;
}
void setPrecision(int num = 20) {
    std::cout << std::fixed << std::setprecision(num);
}
template <typename T>
T Max(T a) {
    return a;
}
template <typename T, typename... Args>
T Max(T a, Args... args) {
    return std::max(Max(args...), a);
}
template <typename T>
T Min(T a) {
    return a;
}
template <typename T, typename... Args>
T Min(T a, Args... args) {
    return std::min(Min(args...), a);
}
template <typename T>
bool vector_contains(std::vector<T> vec, T value) {
    return (std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value)) != vec.size());
}
template <typename T>
long indexOf(std::vector<T> &vec, const T &value) {
    auto result = std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value));
    return ((long)result == (long)vec.size()) ? -1 : result;
}
template <typename T>
void removeAt(std::vector<T> &vec, unsigned int index) {
    vec.erase(vec.begin() + index);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &value) {
    std::fill((T *)array, (T *)(array + N), value);
}
const Int MAX = 510000LL;
const Int MOD = 1000000007LL;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    // 前処理
    COMinit();
    Int n, k;
    cin >> n >> k;
    auto v = IntsIn(n);
    auto b = vector<pair<Int, Int>>();
    auto s = vector<Int>();
    auto t = vector<Int>();
    sort(ALL(v));
    Int prev = -1e10;
    Int currentIndex = -1;
    for (auto a : v) {
        if (a == prev) {
            b[currentIndex].second++;
        } else {
            currentIndex++;
            b.PB(MP(a, 1));
        }
        prev = a;
    }
    Int current = 0;
    for (auto bi : b) {
        current += bi.second;
        s.PB(current);
    }
    current = 0;
    for (auto itr = b.rbegin(); itr != b.rend(); itr++) {
        current += (*itr).second;
        t.PB(current);
    }
    Int ans = 0LL;
    rep(i, SZ(b)) {
        auto bi = b[i].F;
        if (s[i] >= k) {
            Int r = COM(s[i], k);
            if (i > 0 && s[i - 1] >= k) {
                r -= COM(s[i - 1], k);
            }
            ans += bi * r;
            ans %= MOD;
        }
    }
    Int ans2 = 0LL;
    for (int i = SZ(b) - 1; i >= 0; i--) {
        auto bi = b[i].F;
        int j = SZ(b) - 1 - i;
        if (t[j] >= k) {
            Int r = COM(t[j], k);
            if (j > 0 && t[j - 1] >= k) {
                r -= COM(t[j - 1], k);
            }
            ans2 += bi * r;
            ans2 %= MOD;
        }
    }
    PUTS((ans - ans2 + 2 * MOD) % MOD);
}
