#[test]
fn test_solve() {
    assert_eq!(solve("4 2\n1 1 3 4\n"), "11\n");
    assert_eq!(solve("6 3\n10 10 10 -10 -10 -10\n"), "360\n");
    assert_eq!(solve("3 1\n1 1 1\n"), "0\n");
    assert_eq!(solve("10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n"), "999998537\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut a: Vec<i64> = (0..n).map(|_| sc.read()).collect();
    a.sort();

    let mut fact = vec![Finite(1)];
    for i in 1..n+1 {
        let tmp = fact[i-1] * i as u64;
        fact.push(tmp);
    }
    let cmb = |n: usize, r: usize| fact[n] / fact[n-r] / fact[r];

    let mut ans = Finite(0);

    for i in k-1..n {
        ans += cmb(i,k-1) * (MOD as i64 + a[i]) as u64;
    }

    for i in 0..n-k+1 {
        ans -= cmb(n-i-1,k-1) * (MOD as i64 + a[i]) as u64; 
    }

    format!("{}\n", ans)
}

const MOD: u64 = 1_000_000_007;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct Finite(u64);
impl Finite {
    pub fn new(n: u64) -> Self {
        Finite(n % MOD)
    }
    pub fn pow(self, mut exp: u32) -> Self {
        let mut base = self.0;
        let mut acc = 1;
        while exp > 1 {
            if (exp & 1) == 1 {
                acc = acc * base % MOD;
            }
            exp >>= 1;
            base = base * base % MOD;
        }
        if exp == 1 {
            acc = acc * base % MOD;
        }
        Finite(acc)
    }
}
impl std::fmt::Display for Finite {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
impl std::ops::Add for Finite {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {
        Finite((self.0 + rhs.0) % MOD)
    }
}
impl std::ops::Add<u64> for Finite {
    type Output = Self;
    fn add(self, rhs: u64) -> Self {
        Finite((self.0 + rhs) % MOD)
    }
}
impl std::ops::AddAssign for Finite {
    fn add_assign(&mut self, rhs: Self) {
        self.0 = (self.0 + rhs.0) % MOD;
    }
}
impl std::ops::AddAssign<u64> for Finite {
    fn add_assign(&mut self, rhs: u64) {
        self.0 = (self.0 + rhs) % MOD;
    }
}
impl std::ops::Sub for Finite {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self {
        Finite((self.0 + MOD - rhs.0) % MOD)
    }
}
impl std::ops::Sub<u64> for Finite {
    type Output = Self;
    fn sub(self, rhs: u64) -> Self {
        Finite((self.0 + MOD - rhs) % MOD)
    }
}
impl std::ops::SubAssign for Finite {
    fn sub_assign(&mut self, rhs: Self) {
        self.0 = (self.0 + MOD - rhs.0) % MOD;
    }
}
impl std::ops::SubAssign<u64> for Finite {
    fn sub_assign(&mut self, rhs: u64) {
        self.0 = (self.0 + MOD - rhs) % MOD;
    }
}
impl std::ops::Mul for Finite {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {
        Finite(self.0 * rhs.0 % MOD)
    }
}
impl std::ops::Mul<u64> for Finite {
    type Output = Self;
    fn mul(self, rhs: u64) -> Self {
        Finite(self.0 * rhs % MOD)
    }
}
impl std::ops::MulAssign for Finite {
    fn mul_assign(&mut self, rhs: Self) {
        self.0 = self.0 * rhs.0 % MOD;
    }
}
impl std::ops::MulAssign<u64> for Finite {
    fn mul_assign(&mut self, rhs: u64) {
        self.0 = self.0 * rhs % MOD;
    }
}
impl std::ops::Div for Finite {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {
        self * rhs.pow((MOD - 2) as u32)
    }
}
impl std::ops::Div<u64> for Finite {
    type Output = Self;
    fn div(self, rhs: u64) -> Self {
        self * Finite(rhs).pow((MOD - 2) as u32)
    }
}
impl std::ops::DivAssign for Finite {
    fn div_assign(&mut self, rhs: Self) {
        *self = *self * rhs.pow((MOD - 2) as u32);
    }
}
impl std::ops::DivAssign<u64> for Finite {
    fn div_assign(&mut self, rhs: u64) {
        *self = *self * Finite(rhs).pow((MOD - 2) as u32);
    }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}

Measured memory_bytes: 8444