import Control.Applicative
import Control.Monad
 

main :: IO ()
main = do
    [a, b] <- map read . words <$> getLine
    nss <- map read . words <$> getLine
    putStrLn $ show (solve b nss)

solve :: Int -> [Int] -> Int
solve k nss = mod (sum (map (\x -> maximum x - minimum x) (comb k nss))) 1000000007


comb :: Int -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs