import Control.Monad
import Data.List

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

main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    ak <- map read . words <$> getLine :: IO [Integer]
    let x = last $ sort [product xs | xs <- (comb k ak)]
    print $ x `mod` (1000000007)