#include <bits/stdc++.h>

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

struct Number{
    std::random_device rd;
    long long gcd(long long a, long long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    long long egcd(long long a, long long b, long long &x1, long long &y1) {
        if (!b) {
            x1 = 1;
            y1 = 0;
            return a;
        }
        long long x2, y2;
        long long r = egcd(b, a % b, x2, y2);
        x1 = x2 * 0 + y2 * 1;
        y1 = x2 * 1 - y2 *(a/b);
        return r;
    }
    int mod(string& str, int m) {
        int val = 0;
        for (auto c: str) {
            int a = c - '0';
            val = (1ll * val * 10 + a) % m;
        }
        return val;
    }
    int mul_mod(int a, int b, int m) {
        return a * 1ll * b % m;
    }
    long long mul_mod(long long a, long long b, long long m) {
        long long ans = 0;
        a %= m;
        b %= m;

        while (b) {
            if (b & 1ll) {
                ans = ans + a;
                if (ans >= m)
                    ans -= m;
            }
            a <<= 1;
            if (a >= m)
                a -= m;
            b >>= 1;
        }

        return ans;
    }
    int pow_mod(int a, int n, int m) {
        return pow_mod(a, 1ll * n, m);
    }
    int pow_mod(int a, long long n, int m) {
        if (n == 0)
            return 1 % m;
        if (n == 1)
            return a % m;
        int ans = pow_mod(a, n / 2, m);
        ans = 1ll * ans * ans % m;
        if (n % 2)
            ans = 1ll * ans * a % m;
        return ans;
    }
    long long pow_mod(long long a, long long n, long long m) {
        long long ans = 1;

        while (n) {
            if (n & 1) {
                ans = mul_mod(ans, a, m);
            }
            n >>= 1;
            a = mul_mod(a, a, m);
        }

        return ans;
    }
    int pow_mod(string&str1, string& str2, int m) {
        int p1 = mod(str1, m);
        int val = 1;
        for (auto c: str2) {
            val = pow_mod(val, 10, m);
            int tmp = pow_mod(p1, c - '0', m);
            val = mul_mod(val, tmp, m);
        }
        return val;
    }
    int divide_mod_with_fermat(int a, int b, int m) {
        int inv_b = modular_multiplicative_inverse_with_fermat(b, m);
        return 1ll * a * inv_b % m;
    }

    int divide_mod_with_egcd(int a, int b, int m) {
        int inv_b = modular_multiplicative_inverse_with_egcd(b, m);
        return 1ll * a * inv_b % m;
    }

    int modular_multiplicative_inverse_with_fermat(int a, int m) {
        return pow_mod(a, m - 2, m);
    }

    int modular_multiplicative_inverse_with_egcd(int a, int m) {
        long long x, y;
        long long g = egcd(a, m, x, y);
        if (g != 1)
            return -1;
        return (x % m + m) % m;
    }

    bool fermat_primality_test(long long n) {
        std::uniform_int_distribution<long long> dist(0, numeric_limits<long long>::max());
        if (n == 2 || n == 3)
            return true;
        if (n % 2  == 0)
            return false;
        if (n % 3 == 0)
            return false;
        for (int i = 0; i < 10; i++) {
            long long a = dist(rd) % (n - 4) + 2;
            long long val = pow_mod(a, n -1 , n);
            if (val != 1)
                return false;
        }
        return true;
    }

    bool miller_rabin_primality_test(long long n) {
        uniform_int_distribution<long long> dist(2, n - 2);
        if (n == 2 || n == 3)
            return true;
        if (n % 2 == 0)
            return false;
        if (n % 3 == 0)
            return false;
        int R = 0;
        long long D = n - 1;
        while (D % 2 == 0) {
            R += 1;
            D /= 2;
        }
        int cnt = 10;
        while (cnt--) {
            long long A = dist(rd);
            long long X = pow_mod(A, D, n);
            if (X == 1 || X == n - 1)
                continue;
            int flag = 0;
            for (int i = 1; i < R; i++) {
                X = mul_mod(X, X, n);
                if (X == 1)
                    return false;
                if (X == n - 1) {
                    flag = 1;
                    break;
                }
            }
            if (flag == 1)
                continue;
            return false;
        }
        return true;
    }
};

Number number;

template<typename T>
struct Combinatorics {
    int n;
    T mod;
    vector<T> A;
    Combinatorics(int n, T mod) {
        this-> n = n;
        this->mod = mod;
        A.resize(n + 1);
        A[0] = 1;
        for (int i = 1; i <= n; i++)
            A[i] = number.mul_mod(A[i-1], i, mod);
    }

    T query_factorial_value(int n) {
        return A[n];
    }

    T query_permutation_value(int n, int r) {
        if (r >= 0 && r <= n) {
            T ans = A[n];
            if (n -r >= 0) {
                ans = number.divide_mod_with_fermat(ans, A[n-r], mod);
            }
            return ans;
        }
        return 0;
    }

    T query_combination_value(int n, int r) {
        if (r >= 0 && r <= n) {
            int ans = A[n];
            if (n -r >= 0)
                ans = number.divide_mod_with_fermat(ans, A[n-r], mod);
            ans = number.divide_mod_with_fermat(ans, A[r], mod);
            return ans;
        }
        return 0;
    }

    T query_multiple_combination_value(vector<int>& B) {
        int total = 0;
        for (auto b: B)
            total += b;
        T ans = A[total];
        for (auto b: B) {
            ans = number.divide_mod_with_fermat(ans, A[b], mod);
        }
        return ans;
    }

    T query_string_combination_value(const string& str, int left, int right) {
        map<char, int> M;
        vector<int> A;
        for (int i = left; i <= right; i++)
            M[str[i]]++;
        for (auto p: M)
            A.push_back(p.second);
        return query_multiple_combination_value(A);
    }
};

int mod = 1e9 + 7;
Combinatorics<int> comb(1e5 + 100, mod);

int solve(vector<int>& A, int k) {
    int n = A.size();
    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = k - 1; i < n; i++) {
        int cnt = comb.query_combination_value(i, k - 1);
        ans = (ans + number.mul_mod(cnt, A[i], mod)) % mod;
    }
    for (int i = 0; i + k <= n; i++) {
        int cnt = comb.query_combination_value(n - i - 1, k - 1);
        ans = (0ll + ans - number.mul_mod(cnt, A[i], mod) + mod) % mod;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    vector<int> A;
    cin >> n >> k;
    A.resize(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    int ans = solve(A, k);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024