import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.functional;
import std.traits;

pure nothrow @nogc
T gcdext(T) (T a, T b, ref T x, ref T y) {
  if (!b) {
    x = 1;
    y = 0;
    return a;
  }
  T res = gcdext (b, a % b, y, x);
  y -= x * (a / b);
  return res;
}

struct IntM(int q = 1_000_000_007) {
  alias N = IntM!q;
  private:
  int v;
  pure nothrow @nogc
  static int from(T) (const T m) if (isIntegral!T) {
    int v = m % q;
    static if (isSigned!T) {
      if (v < 0) {
        v += q;
      }
    }
    return v;
  }
  public:
  pure nothrow @nogc
  this(T) (const T m) if (isIntegral!T) {
    v = from!T (m);
  }
  pure nothrow @nogc
  N opAssign(T) (const T m) if (isIntegral!T) {
    v = from!T (m);
    return this;
  }
  pure nothrow @nogc
  N opUnary (string op : "-")() const {
    return N (-v);
  }
  pure nothrow @nogc
  ref N opUnary (string op : "++")() {
    if (++v >= q) {
      v -= q;
    }
    return this;
  }
  pure nothrow @nogc
  ref N opUnary (string op : "--")() {
    if (--v < 0) {
      v += q;
    }
    return this;
  }
  pure nothrow @nogc
  ref N opOpAssign (string op : "+")(in N rhs) {
    v = (v + rhs.v) % q;
    return this;
  }
  pure nothrow @nogc
  ref N opOpAssign (string op : "-")(in N rhs) {
    v = (v - rhs.v + q) % q;
    return this;
  }
  pure nothrow @nogc
  ref N opOpAssign (string op : "*")(in N rhs) {
    v = (v.to!(long) * rhs.v) % q;
    return this;
  }
  pure nothrow @nogc
  ref N opOpAssign (string op : "/")(in N rhs) {
    return this *= rhs.inversion ();
  }
  pure nothrow @nogc
  ref N opOpAssign (string op)(in int rhs) if (op == "+" || op == "-" || op == "*" || op == "/") {
    mixin ("return this " ~ op ~ "= N(rhs);");
  }
  pure nothrow @nogc
  N opBinary (string op)(in N rhs) const if (op == "+" || op == "-" || op == "*" || op == "/") {
    N t = this;
    mixin ("t " ~ op ~ "= rhs;");
    return t;
  }
  pure nothrow @nogc
  N opBinary(string op,T)(const T rhs) const if (isIntegral!T && (op == "+" || op == "-" || op == "*" || op == "/")) {
    mixin ("return this " ~ op ~ " N(rhs);");
  }
  pure nothrow @nogc
  N opBinaryRight(string op,T)(const T rhs) const if (isIntegral!T && (op == "+" || op == "*")) {
    mixin ("return this " ~ op ~ " N(rhs);");
  }
  pure nothrow @nogc
  N inversion () const {
    int x, y;
    immutable g = gcdext!int (v, q, x, y);
    assert (g == 1);
    return N (x);
  }
  pure nothrow @nogc
  int opCast(T : int)() const { return v; }
  pure nothrow @nogc
  int opCmp (const N rhs) const {
    if (v < rhs.v) {
      return -1;
    }
    if (v > rhs.v) {
      return 1;
    }
    return 0;
  }
  pure nothrow
  string toString() const { return v.text; }
}

alias N = IntM!1_000_000_007;

void main() {
  int n, k;
  readf (" %d %d", &n, &k);
  if (k == 1) {
    writeln (0);
    return;
  }
  auto a = new int[n];
  foreach (i; 0 .. n) readf (" %d", &a[i]);
  sort (a);
  auto s = new N[n];
  s[0] = N (a[0]);
  foreach (i; 1 .. n) {
    s[i] = s[i-1] + N (a[i]);
  }
  debug stderr.writeln (s);
  //binomial (l - 2, k - 2)
  auto f = uninitializedArray!(N[]) (n + 1), g = uninitializedArray!(N[]) (n + 1);
  f[0] = g[0] = N (1);
  foreach (i; 1 .. n + 1) {
    f[i] = f[i-1] * N (i);
    g[i] = f[i].inversion ();
  }
  N ss (int k) {
    if (k < 0) return N (0);
    return s[k];
  }
  N res = N (0);
  N binomial (int n, int k) {
    return f[n] * g[k] * g[n-k];
  }
  foreach (l; k .. n + 1) {
    N b = binomial (l - 2, k - 2); 
    //i + l = n
    //i = n - l
    N neg = ss (n - l);
    N pos = s.back - ss (l - 2);
    debug stderr.writeln ("l = ", l);
    debug stderr.writefln ("b = %s, neg = %s, pos = %s, res = %s", b, neg, pos, res);
    res += (pos - neg) * b;
  }
  writeln (res);
}

