import Control.Monad
import Data.List

combinations n = filter ((== n) . length) . subsequences
main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    ak <- map read . words <$> getLine :: IO [Integer]
    let x = last $ sort [product xs | xs <- (combinations k ak)]
    print $ x `mod` ((10^9)+7)