import java.util.*;
import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static final double EPS = 1e-9;
	static long mod = 1000000007;
	static int inf = (int) 1e9 + 2;
	static long[] fac;
	static Long[] a;
	static int[] si;
	static ArrayList<Integer> primes;
	static ArrayList<Integer>[] ad;
	static ArrayList<pair>[] d;
	static edge[] ed;
	static int[][] vis;
	static int[] l, ch;
	static int[] occ, p;
	static Queue<Integer>[] can;
	static String s;
	static int[][][][] memo;
	static int n, m, k;
	static qu[] ar;
	static int[] d1, d2, ans;
	static TreeSet<String> tsSet;
	static char[][] grid;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = sc.nextInt();
		k = sc.nextInt();
		a = new Long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		if (k == 1) {
			System.out.println(0);
			return;
		}
		if (k == 2) {
            long ans=0;
            long sum=0;
            for(int i=0;i<n;i++)
            	sum+=a[i];
            for(int i=0;i<n;i++) {
            	ans=(ans+sum-a[i]*1l*(n-i)+mod)%mod;
            	sum-=a[i];
            }
            System.out.println(ans);
			return;
		}
		fac = new long[n + 1];
		fac[0] = 1l;
		for (int i = 1; i <= n; i++)
			fac[i] = (i*1l * fac[i - 1])%mod;


		long ans = 0;
		long mulp = 0;
		long muln = 0;
 
		for (int i = k - 2; i <= n - 2; i++)
			mulp = (mulp + c(i, k - 2)) % mod;
 
		Arrays.sort(a);
		for (int i = n - 1; i >= 0; i--) {
			if (i + 1 >= k) {
				ans = (ans + mulp * a[i]) % mod;
			}
			if (n - i >= k) {
				ans = (ans - muln * a[i]) % mod;
			}
			if (i > 0 && i - 1 >= k - 2)
				mulp = (mulp - c(i - 1, k - 2) + mod) % mod;
			if (n-i-1 >= 0 && n-i-1 >= k - 2)
				muln = (muln + c(n-i-1, k - 2)) % mod;
 
		}
		while (ans < 0)
			ans += mod;
		out.println(ans % mod);
		out.flush();
	}

	static long c(int n, int r) {
		return (((fac[n] * inver(fac[r])) % mod) * inver(fac[n - r])) % mod;
	}

	static class qu implements Comparable<qu> {
		long a, b, c;

		qu(long i, long v, long x) {
			a = i;
			b = v;
			c = x;
		}

		public String toString() {
			return a + " " + b + " " + c;
		}

		public int compareTo(qu o) {
			if (Math.abs(o.a - o.b) <= Math.abs(a - b) && Math.abs(o.a - o.b) <= Math.abs(a - c))
				return 1;
			if (Math.abs(o.a - o.c) <= Math.abs(a - b) && Math.abs(o.a - o.c) <= Math.abs(a - c))
				return 1;
			else
				return -1;
		}
	}

	static class seg implements Comparable<seg> {
		int a;
		int b;

		seg(int s, int e) {
			a = s;
			b = e;
		}

		public String toString() {
			return a + " " + b;
		}

		public int compareTo(seg o) {
			// if(a==o.a)
			return o.b - b;
			// return
		}
	}

	static class pair {
		int to;
		int number;

		pair(int t, int n) {
			number = n;
			to = t;
		}

		public String toString() {
			return to + " " + number;
		}
	}

	static long modPow(long a, int e)

	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long inver(long x) {
		long a = x;
		long e = (mod - 2);
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1) {
				res = ((1l * res * a) % mod);
			}
			a = ((1l * a * a) % mod);
			e >>= 1;
		}
		return res % mod;
	}

	static class edge implements Comparable<edge> {
		int from;
		int to;
		int number;

		edge(int f, int t, int n) {
			from = f;
			to = t;
			number = n;
		}

		public String toString() {
			return from + " " + to + " " + number;
		}

		public int compareTo(edge f) {
			return f.number - number;
		}
	}

	static void seive(int N) {
		si = new int[N];
		primes = new ArrayList<>();
		si[1] = 1;
		for (int i = 2; i < N; i++) {
			if (si[i] == 0) {
				si[i] = i;
				primes.add(i);
			}
			for (int j = 0; j < primes.size() && primes.get(j) <= si[i] && (i * primes.get(j)) < N; j++)
				si[primes.get(j) * i] = primes.get(j);

		}
	}

	static long fac(int n) {
		if (n == 0)
			return fac[n] = 1;
		if (n == 1)
			return fac[n] = 1;
		long ans = 1;
		for (int i = 1; i <= n; i++)
			fac[i] = ans = (i % mod * ans % mod) % mod;
		return ans % mod;
	}

	static long gcd(long a, long b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static class unionfind {
		int[] p;
		int[] size;
		int[] max;
		int num;

		unionfind(int n) {
			p = new int[n];
			size = new int[n];
			max = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = i;
				max[i] = i;
			}
			Arrays.fill(size, 1);
			num = n;
		}

		int findSet(int v) {
			if (v == p[v])
				return v;

			max[v] = Math.max(max[v], max[p[v]]);

			p[v] = findSet(p[v]);

			max[v] = Math.max(max[v], max[p[v]]);

			return p[v];
		}

		boolean sameSet(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return true;
			return false;
		}

		int max() {
			int max = 0;
			for (int i = 0; i < size.length; i++)
				if (size[i] > max)
					max = size[i];
			return max;
		}

		boolean combine(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return true;
			// System.out.println(num+" ppp");
			num--;
			if (size[a] > size[b]) {
				p[b] = a;
				max[a] = Math.max(max[a], max[b]);
				size[a] += size[b];

			} else {
				p[a] = b;
				max[b] = Math.max(max[a], max[b]);
				size[b] += size[a];
			}
			return false;
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 46096