using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// using System.Numerics;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using ll=System.Int64;
using static Contest_E.MyIO;



public class Contest_E
{
	static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
	static void swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) swap1(ref a, ref b); }  // b の方が小さければ交換
	static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; }  // b の方が小さければ a を更新
	static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; }  // b の方が大きければ a を更新
	static bool inside(long i, long n) => (0<=i&&i<n);
	static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h));
	static T min<T>(params T[] a) where T : IComparable => a.Min();
	static T max<T>(params T[] a) where T : IComparable => a.Max();
	static long mod(long a, long m) { var v = a%m; return (v<0?v+m:v); }
	static T[][] init<T>(long len1,long len2,T val) where T : struct { T[][] m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; }
	static T[][][] init<T>(long len1,long len2,long len3,T val) where T : struct { T[][][] m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = init(len2,len3,val); return m; }
	public const long MOD1 = 1000000007; // 10^9+7
	public const double EPS1 = 1e-8;
	public const long INF1 = 1000000000000000;  // 10^15

	public static void Main() {
		checked{
			long  n, k;
			MyIO.RM(out n, out k);
			ll[] a;
			RA(out a);
			Array.Sort(a);
			ModCombination mc = new ModCombination(n+2,MOD1);
			ModInt ans = new ModInt(0,MOD1);
			for (int i = 0; i < n; i++)
			{
				if(k-1<=n-i-1) ans-=mc.C(n-i-1,k-1)*a[i];
				if(k-1<=i) ans+=mc.C(i,k-1)*a[i];
			}



			MyIO.WM(ans.Value);
		}
	}

public struct ModInt {
	public long Value, Modulo;
//	public System.Numerics.BigInteger Value, Modulo;

	public ModInt(long value) : this(value, long.MaxValue) {}
	public ModInt(long value, long modulo) {
//	public ModInt(System.Numerics.BigInteger value, System.Numerics.BigInteger modulo) {
		this.Modulo = modulo;
		this.Value = value >= 0 ? value % modulo : (modulo - (-value) % modulo) % modulo;
	}

    public static implicit operator ModInt(long v) => new ModInt(v, 1000000007L);
	public static ModInt operator-(ModInt a) => new ModInt(-1*a.Value, a.Modulo); 
	public static ModInt operator+(ModInt a, ModInt b) => new ModInt(a.Value + b.Value, a.Modulo); 
	public static ModInt operator-(ModInt a, ModInt b) => new ModInt(a.Value - b.Value, a.Modulo); 
	public static ModInt operator*(ModInt a, ModInt b) => new ModInt(a.Value * b.Value, a.Modulo); 
	public static ModInt operator/(ModInt a, ModInt b) => a * b.Inverse(); 
	public static bool operator==(ModInt a, ModInt b) => a.Equals(b); 
	public static bool operator!=(ModInt a, ModInt b) => !a.Equals(b); 

	public ModInt Inverse() {
		long a = this.Value, b = this.Modulo, u = 1, v = 0, t, s;
//		System.Numerics.BigInteger a = this.Value, b = this.Modulo, u = 1, v = 0, t, s;
		while(b > 0) {
			t = a / b;
			s = a - t * b; a = b; b = s;
			s = u - t * v; u = v; v = s;
		}
		return new ModInt(u, this.Modulo);
	}

	public ModInt Pow(long n) {
		ModInt ret = new ModInt(1, this.Modulo);
		ModInt mul = this;
		while(n > 0) {
			if((n & 1)==1) ret *= mul;
			mul *= mul;
			n >>= 1;
		}
		return ret;
	}

    public override bool Equals(object obj) {
        if (!(obj is ModInt)) throw new ArgumentException("Object is not a ModInt");
        return Equals((ModInt)obj);   
    }
    public bool Equals(ModInt p) => (this.Value == p.Value);
    public override int GetHashCode() => (int)(this.Value ^ this.Modulo);
	public override string ToString() => this.Value.ToString();

}


// n! nPr nCr nHr B(n,k) S{nk} P(n,k) を求める。
// ModCombinationは結果をmod     ※ ModInt クラスが必要
// ベル数 B(n,k)
//   区別できる n個のボールを区別できない k個以下の箱に分割する方法の数を与える。
//   特に B(n,n)は n 個のボールを任意個のグループに分割する方法の数である。
// 第2種スターリング数 S{nk}
//   区別できる n 個のボールを区別できない k 個の箱に分割する方法の数を与える。
// 分割数テーブル
//   分割数 P(n,k) は整数 n をちょうど k 個の非負整数の和で表す方法の数を与える。
//   順序が異なるものは同一視する。
public class ModCombination {
	private ModInt[] _fact, _rfact, _inv, _seq;

	public ModCombination(long sz) : this(sz, long.MaxValue) {}
	public ModCombination(long sz, long modulo){
		_fact = new ModInt[sz+1];
		_rfact = new ModInt[sz+1];
		_inv = new ModInt[sz+1];
		_seq = new ModInt[sz+1];

		for(int i = 0; i <= sz; i++) _seq[i] = new ModInt(i,modulo);
		_fact[0] = _rfact[sz] = _inv[0] = _seq[1];
		for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
		_rfact[sz] /= _fact[sz];
		for(int i = (int)sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
		for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
	}

	public ModInt Fact(long n) {
		if(n < 2) return _seq[1];
		return _fact[n];
	}
	public ModInt P(long n, long k) {
		if(k < 0 || n < k) return _seq[0];
		return _fact[n] * _rfact[n - k];
	}
	public ModInt C(long n, long k) {
		if(k < 0 || n < k) return _seq[0];
		return _fact[n] * _rfact[k] * _rfact[n - k];
	}
	public ModInt H(long n, long k) {
		if(n < 0 || k < 0) return _seq[0];
		return k == 0 ? _seq[1] : C(n + k - 1, k);
	}
	public ModInt B(long n, long k) {
		if(n == 0) return _seq[1];
		k = k<n ? k : n;
		ModInt ret = _seq[0];
		ModInt[] pref = new ModInt[k + 1];
		pref[0] = _seq[1];
		for(int i = 1; i <= k; i++) {
			if((i & 1)==1) pref[i] = pref[i - 1] - _rfact[i];
			else pref[i] = pref[i - 1] + _rfact[i];
		}
		for(int i = 1; i <= k; i++) ret += _seq[i].Pow(n) * _rfact[i] * pref[k - i];
		return ret;
	}
	public ModInt S(long n, long k) {
		if (n < 0 || k < 0 || n < k) return _seq[0];
		ModInt ret = _seq[0];
		for(int i = 0; i <= k; i++) {
			ModInt add = _seq[i].Pow(n) * this.C(k, i);
			if(((k - i) & 1)==1) ret -= add;
			else ret += add;
		}
		return ret * _rfact[k];
	}
	public static ModInt[][] PartitionTable(long n, long k, long modulo=long.MaxValue) {
		ModInt[][] dp = new ModInt[n + 1][];
		for(int i=0;i<=n;i++) dp[i] = Enumerable.Repeat(new ModInt(0,modulo), (int)k+1).ToArray();
		dp[0][0] = new ModInt(1, modulo);
		for(int i = 0; i <= n; i++) {
			for(int j = 1; j <= k; j++) {
				if(i - j >= 0) dp[i][j] = dp[i][j - 1] + dp[i - j][j];
				else dp[i][j] = dp[i][j - 1];
			}
		}
		return dp;
	}


}











#region MyIO

public struct VT<T,U>
{
	public T Item1; public U Item2;
    public VT(T a,U b) { Item1 = a; Item2 = b; }
}
public struct VT<T,U,V>
{
	public T Item1; public U Item2; public V Item3;
    public VT(T a,U b,V c) { Item1 = a; Item2 = b; Item3 = c; }
}
public struct VT<T,U,V,W>
{
	public T Item1; public U Item2; public V Item3; public W Item4;
    public VT(T a,U b,V c,W d) { Item1 = a; Item2 = b; Item3 = c; Item4 = d; }
}

public static class MyIO
{
	class Prt : System.IO.StreamWriter
	{
		public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
		public Prt(System.IO.Stream s) : base(s,new UTF8Encoding(false,true)) {}
		public Prt(System.IO.Stream s,Encoding e) : base(s,e) {}
	}
	
	static char[] sp = new char[] {' '};
	[MethodImpl(256)]
	static bool eq<T,U>() => typeof(T).Equals(typeof(U));
	[MethodImpl(256)]
	static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T));
	static T cv<T>(string s) =>
		eq<T,int>()    ? ct<T,int>(int.Parse(s))
	  : eq<T,long>()   ? ct<T,long>(long.Parse(s))
	  : eq<T,double>() ? ct<T,double>(double.Parse(s,System.Globalization.CultureInfo.InvariantCulture))
	  : eq<T,char>()   ? ct<T,char>(s[0])
					   : ct<T,string>(s);
	public static string[] RM<T>(out T a) {
		var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(z[0]);
		return z;
	}
	public static string[] RM<T,U>(out T a,out U b) {
		var z = RM<T>(out a); 
        b = cv<U>(z[1]);
		return z;
	}
	public static string[] RM<T,U,V>(out T a,out U b,out V c) {
		var z = RM<T,U>(out a,out b); 
        c = cv<V>(z[2]);
		return z;
	}
	public static string[] RM<T,U,V,W>(out T a,out U b,out V c,out W d) {
		var z = RM<T,U,V>(out a,out b,out c); 
        d = cv<W>(z[3]);
		return z;
	}
	public static string[] RM<T,U,V,W,X>(out T a,out U b,out V c,out W d,out X e) {
		var z = RM<T,U,V,W>(out a,out b,out c,out d); 
        e = cv<X>(z[4]);
		return z;
	}
	public static string[] RM<T,U,V,W,X,Y>(out T a,out U b,out V c,out W d,out X e,out Y f) {
		var z = RM<T,U,V,W,X>(out a,out b,out c,out d,out e); 
        f = cv<Y>(z[5]);
		return z;
	}
	public static string[] RA<T>(out T[] a) {		
		var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
		a = z.Select(cv<T>).ToArray();
		return z;
	}
	public static string[][] RL<T>(long n,out T[] a) {
		a = new T[n];
		var y = new string[n][];
		for(int i=0;i<n;i++) y[i] = RM(out a[i]);
		return y;
	}
	public static string[][] RL<T,U>(long n,out VT<T,U>[] a) {
		a = new VT<T,U>[n];
		var y = new string[n][];
		for(int i=0;i<n;i++) {
			T o; U p;
			y[i] = RM(out o,out p);
			a[i] = new VT<T,U>(o,p);
		}
		return y;
	}
	public static string[][] RL<T,U,V>(long n,out VT<T,U,V>[] a) {
		a = new VT<T,U,V>[n];
		var y = new string[n][];
		for(int i=0;i<n;i++) {
			T o; U p; V q;
			y[i] = RM(out o,out p,out q);
			a[i] = new VT<T,U,V>(o,p,q);
		}
		return y;
	}
	public static string[][] RL<T,U,V,W>(long n,out VT<T,U,V,W>[] a) {
		a = new VT<T,U,V,W>[n];
		var y = new string[n][];
		for(int i=0;i<n;i++) {
			T o; U p; V q; W r;
			y[i] = RM(out o,out p,out q,out r);
			a[i] = new VT<T,U,V,W>(o,p,q,r);
		}
		return y;
	}
	public static string[][] RX<T>(long n,out T[][] a) {
		a = new T[n][];
		var y = new string[n][];
		for(int i=0;i<n;i++) y[i] = RA(out a[i]);
		return y;
	}

	static void wwp(Action act){
		var s = new Prt(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(s);
		act();
		Console.Out.Flush();
		s.AutoFlush = true;
		Console.SetOut(s);
	}
	[MethodImpl(256)]
	static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
	public static void WM(params object[] a) {
		wwp(()=>{
			for(int i=0;i<a.Length;i++) {
				var f = wfm(a[i].GetType()) + ((i<a.Length-1) ? " " : Environment.NewLine);
				Console.Write(f,a[i]);
			}
		});
	}
	public static void WA<T>(IList<T> a) {
		wwp(()=>{
			var f = wfm(typeof(T));
			var g = f + " ";
			var h = f + Environment.NewLine;
			for(int i=0;i<a.Count;i++) Console.Write(((i<a.Count-1) ? g : h),a[i]);
		});
	}
	public static void WL<T>(IList<T> a) {
		wwp(()=>{
			var f = wfm(typeof(T)) + Environment.NewLine;
			foreach(T x in a) Console.Write(f,x);
		});
	}


}

#endregion


}



Measured memory_bytes: 30044