import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

alias Mint = ModInt!(10^^9 + 7);

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(to!int).array;
    A.sort();
    immutable long MOD = 10^^9 + 7;

    auto comb = new Combinations!(10^^9+7)(N * 2 + 10);
    Mint ans = Mint(0);

    foreach (i; 0..N-K+1) {
        ans -= Mint((A[i]+MOD) %MOD) * comb.nCr(N - i - 1, K - 1);
    }

    foreach (i; K-1..N) {
        ans += Mint(A[i]) * comb.nCr(i, K - 1);
    }

    ans.writeln;
}

// This implementation of ModInt references https://github.com/yosupo06/dunkelheit/blob/master/source/dkh/modint.d

// Manually verified on: https://yukicoder.me/problems/no/117
// Manually verified on: https://atcoder.jp/contests/cpsco2019-s3/tasks/cpsco2019_s3_f

struct ModInt(uint mod) {
    import std.conv : to;

    uint n;

    this(int n) {
        this.n = (n % mod.to!int + mod) % mod;
    }

    this(long n) {
        this.n = (n % mod + mod) % mod;
    }

    private this(uint n) {
        this.n = n;
    }

    string toString() const {
        return to!string(this.n);
    }

    private uint normilize(uint n) const {
        return n < mod ? n : n - mod;
    }

    private ModInt pow(uint n, long x) const {
        long ret = 1;
        long a = n;
        while (x) {
            if (x & 1) ret = ret * a % mod;
            a = a * a % mod;
            x >>= 1;
        }
        return ModInt(to!ulong(ret));
    }

    ModInt opBinary(string op : "+")(ModInt rhs) const {
        return ModInt(normilize(n + rhs.n));
    }

    ModInt opBinary(string op : "-")(ModInt rhs) const {
        return ModInt(normilize(n + mod - rhs.n));
    }

    ModInt opBinary(string op : "*")(ModInt rhs) const {
        return ModInt(to!uint(to!long(n) * rhs.n % mod));
    }

    ModInt opBinary(string op : "/")(ModInt rhs) const {
        return this * pow(rhs.n, mod-2);
    }

    ModInt opBinary(string op : "^^")(ModInt rhs) const {
        return pow(this.n, rhs.n);
    }

    ModInt opBinary(string op, T)(T rhs) const {
        ModInt mod_rhs = ModInt(rhs);
        return opBinary!op(mod_rhs);
    }

    ModInt opOpAssign(string op)(ModInt rhs) {
        return mixin ("this=this"~op~"rhs");
    }
}

// require: number/modint.d

// manually verified on: https://atcoder.jp/contests/exawizards2019/tasks/exawizards2019_e
// manually verified on: https://yukicoder.me/problems/no/117

class Combinations(uint mod) {
    alias mint = ModInt!mod;
    mint[] f;

    this(int maxval) {
        f = new mint[](maxval);
        f[0] = f[1] = mint(1);
        foreach(i; 1..maxval-1) {
            f[i+1] = f[i] * (i+1);
        }
    }

    mint nCr(int n, int r) {
        if (n < r) return mint(0);
        return f[n] / f[n-r] / f[r];
    }

    mint nPr(int n, int r) {
        if (n < r) return mint(0);
        return f[n] / f[n-r];
    }

    mint nHr(int n, int r) {
        if (n == 0 && r == 0) return mint(1);
        if (n == 0) return mint(0);
        return f[n+r-1] / f[n-1] / f[r];
    }
}

Measured memory_bytes: 4472