// ReSharper disable ArrangeTypeMemberModifiers
// ReSharper disable ConvertIfStatementToSwitchStatement
// ReSharper disable EnforceIfStatementBraces
// ReSharper disable FunctionRecursiveOnAllPaths
// ReSharper disable InconsistentNaming
// ReSharper disable InlineOutVariableDeclaration
// ReSharper disable InvertIf
// ReSharper disable JoinDeclarationAndInitializer
// ReSharper disable MemberCanBeMadeStatic.Global
// ReSharper disable MemberCanBeMadeStatic.Local
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable NonReadonlyMemberInGetHashCode
// ReSharper disable PossibleNullReferenceException
// ReSharper disable RedundantUsingDirective
// ReSharper disable SuggestVarOrType_BuiltInTypes
// ReSharper disable SuggestVarOrType_Elsewhere
// ReSharper disable TailRecursiveCall
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedMember.Local
// ReSharper disable UseObjectOrCollectionInitializer

// ReSharper disable FieldCanBeMadeReadOnly.Global

#if true && UTAKA_LOCAL

//#if false
#define UTAKA_DEBUG
#endif

//#define TOPCODER

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using static UtakaApp.Util;

// ReSharper disable UnusedType.Global

namespace UtakaApp
{
    public partial class Program
    {
        /*
        https://atcoder.jp/contests/abc151/tasks/abc151_d
        */

        public const string SiteName    = "AtCoder";
        public const string ContestName = "abc151";
        public const string ProblemName = "E";

        public void Solve()
        {
            int N = cin.ReadInt;
            int K = cin.ReadInt;

            long[] A = cin.ReadLongArray(N);

            Array.Sort(A);

            var mbc = new ModFacts(N);

            Mint minSum = 0;
            Mint maxSum = 0;

            for (int i = 0; i < N - K + 1; i++)
            {
                Mint val = mbc.Comb(N - i - 1, K - 1);

                minSum += (val * A[i]);

                maxSum += (val * A[N - 1 - i]);
            }

            Mint ans = maxSum - minSum;

            cou.WriteLine(ans);
        }

        /// <summary>
        /// 階乗を扱う処理
        /// </summary>
        public class ModFacts
        {
            public long[] fac;  // fac[i]  := iの階乗
            public long[] fInv; // fInv[i] := 1 / (iの階乗)
            public long[] inv;  // inv[i]  := 1 / i

            public int MaxN; // 計算対象のNの最大値

            public long Mod;

            public ModFacts(int maxN, long mod = 1000000007, bool shouldInit = true)
            {
                MaxN = maxN;

                Mod = mod;

                if (!shouldInit)
                {
                    return;
                }

                fac  = new long[maxN + 1];
                fInv = new long[maxN + 1];
                inv  = new long[maxN + 1];

                // 事前計算
                fac[0]  = fac[1]  = 1;
                fInv[0] = fInv[1] = 1;
                inv[1]  = 1;

                for (int i = 2; i < MaxN + 1; i++)
                {
                    fac[i]  = fac[i - 1] * i % Mod;
                    inv[i]  = Mod - inv[Mod % i] * (Mod / i) % Mod;
                    fInv[i] = fInv[i - 1] * inv[i] % Mod;
                }
            }

            // public long Inv(long a) =

            // public long Pow(long a, long b, long mod)
            // {
            //     a %= mod;
            //     if (b < 0) throw new[]
            // }

            /// <summary>
            /// a^n mod.n を計算する
            /// </summary>
            public long ModPow(long a, long n, long mod = 1000000007)
            {
                long res = 1;
                while (n > 0)
                {
                    if ((n & 1) != 0) res = res * a % mod;
                    a =   a * a % mod;
                    n >>= 1;
                }

                return res;
            }

            // public Mint[] mpows;
            //
            // /// <summary>
            // /// baseValue ^ exponent までの配列を用意する
            // /// </summary>
            // public void InitMpows(int baseValue, int exponent)
            // {
            //     mpows    = new Mint[exponent + 1];
            //     mpows[0] = 1;
            //     for (int i = 1; i <= exponent; i++)
            //     {
            //         mpows[i] = mpows[i - 1] * baseValue;
            //     }
            // }
            //
            // public long[] pows;
            //
            // /// <summary>
            // /// baseValue ^ exponent までの配列を用意する
            // /// </summary>
            // public void InitPows(int baseValue, int exponent, long mod = 1000000007L)
            // {
            //     pows    = new long[exponent + 1];
            //     pows[0] = 1;
            //     for (int i = 1; i <= exponent; i++)
            //     {
            //         pows[i] =  pows[i - 1] * baseValue;
            //         pows[i] %= mod;
            //     }
            // }


            /// <summary>
            /// nCkを求める
            /// nはmaxN以下である必要がある
            /// </summary>
            public long Comb(int n, int k)
            {
                if (MaxN < n)
                {
                    throw new InvalidOperationException("n is larger than MaxN!");
                }

                if (n < k) return 0;
                if (n < 0 || k < 0) return 0;

                // if (fac != null)
                {
                    return fac[n] * (fInv[k] * fInv[n - k] % Mod) % Mod;
                }

                // long ans = 1;
                //
                // // long
                // // numerator denominator
                //
                // long numer = 1;
                // long denom = 1;
                //
                // for (long i = 0; i < k; i++)
                // {
                //     numer = numer * ((n - 1) % Mod) % Mod;
                //     denom = denom * ((i + 1) % Mod) % Mod;
                // }
            }
        }
    }

    // ================
    // @formatter:off
    // ================

    public struct Mint
    {
        public const int MintMod = 1000000007;
        public const long PositiveAddition = ((long)MintMod) << 31;
        public long Value;
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public Mint(long value) { if ((Value = value % MintMod) < 0) { Value += MintMod; } } 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator long(Mint mint) => mint.Value; 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator Mint(long val) => new Mint(val); 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator +(Mint a, int b) => new Mint() {Value = (a.Value + b + PositiveAddition) % MintMod}; 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator +(Mint a, long b) => new Mint(a.Value + b); 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator +(Mint a, Mint b) { long res = a.Value + b.Value; return new Mint() {Value = res >= MintMod ? res - MintMod : res}; } 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator -(Mint a, int b) => new Mint() {Value = (a.Value - b + PositiveAddition) % MintMod}; 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator -(Mint a, long b) => new Mint(a.Value - b); 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator -(Mint a, Mint b) { long res = a.Value - b.Value; return new Mint() {Value = res < 0 ? res + MintMod : res}; } 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator *(Mint a, int b) => new Mint(a.Value * b); 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator *(Mint a, long b) => a * new Mint(b); 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator *(Mint a, Mint b) => new Mint() {Value = a.Value * b.Value % MintMod}; 
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Mint operator /(Mint a, Mint b) => new Mint() {Value = a.Value * GetInverse(b) % MintMod};
        [MethodImpl(MethodImplOptions.AggressiveInlining)] public override string ToString() => Value.ToString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)] static long GetInverse(long a) { long div; long p  = MintMod; long x1 = 1; long y1 = 0; long x2 = 0; long y2 = 1; while (true) { if (p == 1) return x2 + MintMod; div =  a / p; x1  -= x2 * div; y1  -= y2 * div; a   %= p; if (a == 1) return x1 + MintMod; div =  p / a; x2  -= x1 * div; y2  -= y1 * div; p   %= a; } }
    }

    public partial class Program
    {
        private readonly ConsoleInput cin;
        private readonly IConsole     cou;

        public Program(ConsoleInput cin, IConsole cou)
        {
            this.cin = cin;
            this.cou = cou;
        }

#if !TOPCODER
        public static void Main()
        // public static void Main(string[] args)
        {
#if UTAKA_LOCAL
//#if false
            new TestCaseCheckerForAtCoder().TestProblems();
#else
            var cin = new ConsoleInput(System.Console.In);
            var console = new MyConsole();
            new Program(cin, console).Solve();
            console.Flush();
#endif
        }
#endif

        public void WriteEnumerable<T>(IEnumerable<T> A, string delimiter = " ")
        {
            var sb = new StringBuilder();
            foreach (T v in A)
            {
                sb.Append(v);
                sb.Append(delimiter);
            }

            if (sb.Length > 0)
            {
                sb.Length--;
            }

            cou.WriteLine(sb.ToString());
        }
    }

    public static class Util
    {
        //=========================================================================================
        // Library
        //=========================================================================================

        public static T[] Array1D<T>(int a, T defaultValue) where T : struct { var ret = new T[a]; for (int i = 0; i < a; i++) { ret[i] = defaultValue; } return ret; }
        public static T[] Array1D<T>(int a) where T : struct { var ret = new T[a]; return ret; }
        public static T[,] Array2D<T>(int a, int b, T defaultValue) where T : struct { var ret = new T[a, b]; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { ret[i, j] = defaultValue; } } return ret; }
        public static T[,,] Array3D<T>(int a, int b, int c, T defaultValue) where T : struct { T[,,] ret = new T[a, b, c]; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { for (int k = 0; k < c; k++) { ret[i, j, k] = defaultValue; } } } return ret; }
        public static T[][] JagArray2D<T>(int a, int b, T defaultValue) where T : struct { var ret = new T[a][]; for (int i = 0; i < a; i++) { var row = new T[b]; ret[i] = row; for (int j = 0; j < b; j++) { row[j] = defaultValue; } } return ret; }
        public static T[][] JagArray2D<T>(int a, int b) where T : struct { var ret = new T[a][]; for (int i = 0; i < a; i++) { ret[i] = new T[b]; } return ret; }
        public static T[][][] JagArray3D<T>(int a, int b, int c, T defaultValue) where T : struct { var ret = new T[a][][]; for (int i = 0; i < a; i++) { T[][] aRow = new T[b][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[] bRow = new T[c]; aRow[j] = bRow; for (int k = 0; k < c; k++) { bRow[k] = defaultValue; } } } return ret; }
        public static T[][][] JagArray3D<T>(int a, int b, int c) where T : struct { var ret = new T[a][][]; for (int i = 0; i < a; i++) { T[][] aRow = new T[b][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[] bRow = new T[c]; aRow[j] = bRow; } } return ret; }
        public static T[][][][] JagArray4D<T>(int a, int b, int c, int d, T defaultValue) where T : struct { var ret = new T[a][][][]; for (int i = 0; i < a; i++) { T[][][] aRow = new T[b][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][] bRow = new T[c][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[] cRow = new T[d]; bRow[k] = cRow; for (int l = 0; l < d; l++) { cRow[l] = defaultValue; } } } } return ret; } 
        public static T[][][][] JagArray4D<T>(int a, int b, int c, int d) where T : struct { var ret = new T[a][][][]; for (int i = 0; i < a; i++) { T[][][] aRow = new T[b][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][] bRow = new T[c][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[] cRow = new T[d]; bRow[k] = cRow; } } } return ret; }
        public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e, T defaultValue) where T : struct { var ret = new T[a][][][][]; for (int i = 0; i < a; i++) { T[][][][] aRow = new T[b][][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][][] bRow = new T[c][][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[][] cRow = new T[d][]; bRow[k] = cRow; for (int l = 0; l < d; l++) { T[] dRow = new T[e]; cRow[l] = dRow; for (int m = 0; m < e; m++) { dRow[m] = defaultValue; } } } } } return ret; }
        public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e) where T : struct { var ret = new T[a][][][][]; for (int i = 0; i < a; i++) { T[][][][] aRow = new T[b][][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][][] bRow = new T[c][][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[][] cRow = new T[d][]; bRow[k] = cRow; for (int l = 0; l < d; l++) { T[] dRow = new T[e]; cRow[l] = dRow; } } } } return ret; }

        // IListを配列をコピーして配列を返す
        public static T[] CopyArray<T>(IList<T> a) { T[] ret = new T[a.Count]; for (int i = 0; i < a.Count; i++) ret[i] = a[i]; return ret; }

        // ジャグ配列をコピーして返す。
        public static T[][] CopyJagArray2D<T>(T[][] source) where T : struct { int   len  = source.Length; T[][] dest = new T[len][]; for (int i = 0; i < len; i++) { T[] inner       = source[i]; int innerLength = inner.Length; T[] newer       = new T[innerLength]; Array.Copy(inner, newer, innerLength); dest[i] = newer; } return dest; }
    }

    public class IntLargeComparer : IComparer<int>
    {
        public static IntLargeComparer Instance = new IntLargeComparer();

        public int Compare(int x, int y)
        {
            return y - x;
        }
    }

    public class LongLargeComparer : IComparer<long>
    {
        public static LongLargeComparer Instance = new LongLargeComparer();

        public int Compare(long x, long y)
        {
            if (x > y) return -1;
            if (x < y) return 1;
            return 0;
        }
    }

    public class ConsoleInput
    {
        private readonly char          _separator;
        private readonly TextReader    _stream;
        private readonly Queue<string> inputStream;

        public ConsoleInput(TextReader stream, char separator = ' ') { _separator  = separator; _stream     = stream; inputStream = new Queue<string>(); } 
        public string Read { get { if (inputStream.Count != 0) { return inputStream.Dequeue(); } var tmp = _stream.ReadLine().Split(_separator); for (var i = 0; i < tmp.Length; ++i) { inputStream.Enqueue(tmp[i]); } return inputStream.Dequeue(); } } 
        public string ReadLine   => _stream.ReadLine();
        public int    ReadInt    => int.Parse(Read);
        public long   ReadLong   => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) { ret[i] = Read; } return ret; } 
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) { ret[i] = ReadInt; } return ret; } 
        public int[] ReadIntArrayMinus1(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) { ret[i] = ReadInt - 1; } return ret; } 
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) { ret[i] = ReadLong; } return ret; }
    }

    public interface IConsole
    {
        void Flush();
        void Write(object obj);
        void Write(string str);
        void WriteLine(object obj);
        void WriteLine(string str);
        void WriteLine();
    }

    public class MyConsole : IConsole
    {
        public MyConsole() { var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false}; Console.SetOut(sw); } 
        public void Flush() { Console.Out.Flush(); } 
        public void Write(object obj) { Write(obj.ToString()); } 
        public void Write(string str) { Console.Write(str); } 
        public void WriteLine(object obj) { WriteLine(obj.ToString()); } 
        public void WriteLine(string str) { Console.WriteLine(str); } 
        public void WriteLine() { Console.WriteLine(); }
    }

#if UTAKA_LOCAL

    public class DebugConsole : IConsole
    {
        private readonly StringBuilder mSb;

        public DebugConsole() { mSb = new StringBuilder(); } 
        public void Flush() { } 
        public void Write(object obj) { Write(obj.ToString()); } 
        public void Write(string str) { mSb.Append(str); } 
        public void WriteLine(object obj) { WriteLine(obj.ToString()); } 
        public void WriteLine(string str) { mSb.AppendLine(str); } 
        public void WriteLine() { mSb.AppendLine(); }
        public string GetAllOutput() { return mSb.ToString(); }
    }

#endif

#if UTAKA_LOCAL

    public class TestCaseCheckerForAtCoder
    {
        private string GetDirectoryPath()
        {
            var problemPart = string.IsNullOrEmpty(Program.ProblemName)
                ? ""
                : $"/{Program.ProblemName}";

            return
                $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/AlgorithmPrac/{Program.SiteName}/{Program.ContestName}{problemPart}";
        }

        private string GetInputFilePath(int testCaseNumber)
        {
            return $"{GetDirectoryPath()}/sample-{testCaseNumber}.in";
        }

        private string GetOutputFilePath(int testCaseNumber)
        {
            return $"{GetDirectoryPath()}/sample-{testCaseNumber}.out";
        }

        public bool TestProblem(int testCaseNumber)
        {
            var inputFilePath  = GetInputFilePath(testCaseNumber);
            var outputFilePath = GetOutputFilePath(testCaseNumber);

            TextReader inputStream = new StreamReader(inputFilePath);
            var        cin         = new ConsoleInput(inputStream);

            var debugConsoleWriter = new DebugConsole();
            new Program(cin, debugConsoleWriter).Solve();
            var        output       = debugConsoleWriter.GetAllOutput();
            TextReader outputStream = new StreamReader(outputFilePath);
            var        outputAnswer = outputStream.ReadToEnd();

            Dbg.WriteLine(output);
            Dbg.WriteLine(outputAnswer);

            var isCorrect = output == outputAnswer;

            return isCorrect;
        }



        public void TestProblems(int targetTestCaseNumber = -1) { if (targetTestCaseNumber >= 0) { Console.WriteLine($"!!!!!!!!!!!! Check TestCase {targetTestCaseNumber} !!!!!!!!!!"); } bool isSuccessAll = true; int testCaseNumber = 0; while (true) { testCaseNumber++; bool foundTargetTest = targetTestCaseNumber == testCaseNumber; if (targetTestCaseNumber >= 0 && !foundTargetTest) { continue; } var inputFileName = GetInputFilePath(testCaseNumber); if (!File.Exists(inputFileName)) { break; } Console.WriteLine($"TestCase {testCaseNumber} ====================================================="); var result = TestProblem(testCaseNumber); if (result) { Console.WriteLine("Success"); } else { isSuccessAll = false; Console.WriteLine("Failure *****"); } if (foundTargetTest) { break; } } if (isSuccessAll) { Console.WriteLine("!!!!!!!!! All Success !!!!!!!!!"); } }
    }

#endif

    public static class Dbg
    {
        [Conditional("UTAKA_DEBUG")] public static void WriteLine(string str) { Console.WriteLine(str); }
        [Conditional("UTAKA_DEBUG")] public static void WriteLine() { Console.WriteLine(); }
        [Conditional("UTAKA_DEBUG")] public static void Write(string str) { Console.Write(str); }
    }
    
    // ================
    // @formatter:on 
    // ================
}


Measured memory_bytes: 29148