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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine().Split().Select(long.Parse).ToList();
            var N = input1[0];
            var K = input1[1];
            var A = Console.ReadLine().Split().Select(long.Parse).OrderBy(i => i).ToList();
            var mod = 1000000007;

            if (K == 1)
            {
                Console.WriteLine(0);
                return;
            }

            var calculator = new CombinationCalculator(N, mod);

            long ans = 0;
            for (var i = 0; i < N; i++)
            {
                ans = (ans + CalcMax(A, i, K, mod, calculator) - CalcMin(A, i, N, K, mod, calculator)) % mod;
            }

            Console.WriteLine(ans);
        }

        private static long CalcMax(List<long> A, int i, long K, long mod, CombinationCalculator calculator)
        {
            if (i < K - 1) return 0;
            return A[i] * calculator.nCr(i, K - 1) % mod;
        }

        private static long CalcMin(List<long> A, int i, long N, long K, long mod, CombinationCalculator calculator)
        {
            if (N - i - 1 < K - 1) return 0;
            return A[i] * calculator.nCr(N - i - 1, K - 1) % mod;
        }
    }

    public class CombinationCalculator
    {
        public long Max { get; }
        public long Mod { get; }
        public Dictionary<long, long> Factorial { get; }
        public Dictionary<long, long> FactorialInverse { get; }
        private Dictionary<long, long> inverseDict;
        private Dictionary<long, Dictionary<long, long>> nCrDict;

        public CombinationCalculator(long n, long mod)
        {
            Max = n;
            Mod = mod;
            Factorial = new Dictionary<long, long> { { 0, 1 }, { 1, 1 } };
            FactorialInverse = new Dictionary<long, long> { { 0, 1 }, { 1, 1 } };
            inverseDict = new Dictionary<long, long>() { { 1, 1 } };
            nCrDict = new Dictionary<long, Dictionary<long, long>>();

            for (long i = 2; i <= n; i++)
            {
                Factorial.Add(i, Factorial[i - 1] * i % Mod);
                FactorialInverse.Add(i, FactorialInverse[i - 1] * Inverse(i) % Mod);
            }
        }

        public static long ExtGcd(long a, long b, out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }
            var d = ExtGcd(b, a % b, out y, out x);
            y -= a / b * x;
            return d;
        }

        public long Inverse(long a)
        {
            if (inverseDict.ContainsKey(a)) return inverseDict[a];

            long x;
            long y;
            var d = ExtGcd(a, Mod, out x, out y);
            if (d != 1) return -1;
            var inverse = x < 0 ? x + Mod : x;

            inverseDict.Add(a, inverse);
            return inverse;
        }

        public long nCr(long n, long r)
        {
            if (nCrDict.ContainsKey(n) && nCrDict[n].ContainsKey(r)) return nCrDict[n][r];

            var result = (Factorial[n] * FactorialInverse[r] % Mod) * FactorialInverse[n - r] % Mod;
            nCrDictAdd(n, r, result);

            return result;
        }

        private void nCrDictAdd(long n, long r, long result)
        {
            if (nCrDict.ContainsKey(n))
            {
                nCrDict[n].Add(r, result);
                return;
            }

            nCrDict.Add(n, new Dictionary<long, long>() { { r, result } });
        }
    }
}


Measured memory_bytes: 51696