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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Modular
        {
            private const int M = 1000000007;
            private long value;

            public Modular(long value) { this.value = value; }
            public static implicit operator Modular(long a)
            {
                var m = a % M;
                return new Modular((m < 0) ? m + M : m);
            }
            public static Modular operator +(Modular a, Modular b) { return a.value + b.value; }
            public static Modular operator -(Modular a, Modular b) { return a.value - b.value; }
            public static Modular operator *(Modular a, Modular b) { return a.value * b.value; }
            private static Modular Pow(Modular a, int n)
            {
                switch (n)
                {
                case 0:
                    return 1;
                case 1:
                    return a;
                default:
                    var p = Pow(a, n / 2);
                    return p * p * Pow(a, n % 2);
                }
            }
            public static Modular operator /(Modular a, Modular b) { return a * Pow(b, M - 2); }
            private static readonly List<int> facs = new List<int> { 1 };
            private static Modular Fac(int n)
            {
                for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % M)); }
                return facs[n];
            }
            public static Modular Ncr(int n, int r)
            {
                return (n < r) ? 0
                     : (n == r) ? 1
                                : Fac(n) / (Fac(r) * Fac(n - r));
            }
            public static explicit operator int(Modular a) { return (int)a.value; }
        }

        static long Solve(int N, int K, long[] A)
        {
            Array.Sort(A);
            var sum = new Modular(0);
            for (int i = 0; i < N; ++i)
            {
                {
                    int n = i;
                    if (n >= K - 1)
                    {
                        sum += Modular.Ncr(n, K - 1) * A[i];
                    }
                }
                {
                    int n = N - 1 - i;
                    if (n >= K - 1)
                    {
                        sum -= Modular.Ncr(n, K - 1) * A[i];
                    }
                }
            }
            return (long)sum;
        }

        static void Main(string[] args)
        {
            var V = ReadInts();
            var A = ReadLongs();
            Console.WriteLine(Solve(V[0], V[1], A));
        }
    }
}


Measured memory_bytes: 28472