let [|N;K|] =
    stdin.ReadLine().Split()
    |> Array.map int
let A =
    stdin.ReadLine().Split()
    |> Array.map int64
    |> Array.sort
let Mod = 1000000007L

let modPownFun x n =
    let rec f value pown i =
        if i=0L then value
        else
            let newPow = (pown * pown) % Mod
            let newI = i >>> 1
            match i&&&1L with
            | 1L -> f ((value*pown)%Mod) newPow newI
            | 0L -> f value newPow newI
    f 1L x n
let modFactList = List.scan (fun state item -> state * item % Mod) 1L [1L..int64(N)]
let modFactRevList =
    modFactList
    |> List.map (fun item -> modPownFun item (Mod-2L))
let modCombFun n k = modFactList.[n] * modFactRevList.[k] % Mod * modFactRevList.[n-k] % Mod

let maxSum =
    [K-1..N-1]
    |> List.fold (fun state i -> (state + (modCombFun i (K-1))*A.[i]%Mod)%Mod) 0L

[0..N-K]
|> List.fold (fun state i -> (state + Mod - (modCombFun (N-i-1) (K-1))*A.[i]%Mod)%Mod) maxSum
|> stdout.WriteLine