import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto A = aryread();
    if (K == 1)
    {
        writeln(0);
        return;
    }
    auto memo = new long[](N + 1);
    foreach (r; 0 .. N + 1)
        memo[r] = combination_mod(r, K - 2, MOD);
    A.sort();
    long ans;
    foreach (i; 0 .. N - K + 1)
        foreach (j; i + K - 1 .. N)
        {
            long val = A[j] - A[i];
            long range = j - i - 1;
            long cnt = memo[range];
            // writefln("%s,%s:\t%s\t%s\t%s", i, j, range, cnt, val);
            ans = (ans + val * cnt) % MOD;
        }
    writeln(ans);
}

T combination_mod(T = long)(T n, T k, T m)
{
    if (n < k)
        return 0;
    long a = 1;
    long b = 1;
    long c = 1;
    foreach (i; 1 .. n + 1)
    {
        a = (a * i) % m;
        if (i == k)
            b = a;
        if (i == (n - k))
            c = a;
    }
    T powmod(T = long)(T x, T n, T m)
    {
        if (n < 1)
            return 1;
        if (n & 1)
        {
            return x * powmod(x, n - 1, m) % m;
        }
        T tmp = powmod(x, n / 2, m);
        return tmp * tmp % m;
    }

    long bc = b * c % m;
    long bc_inv = powmod(bc, m - 2, m);
    return a * bc_inv % m;
}
