{-# LANGUAGE TypeApplications #-}

module Main where

import Control.Monad (filterM)

main :: IO ()
main = do
  (n : k : _) <- map (read @Int) . words <$> getLine
  as <- filter ((==) k . length) . powerset . map read . words <$> getLine
  let maxP = maximum [ product ps | ps <- as ]
  print $ maxP `mod` 1000000007
  where
    powerset :: [a] -> [[a]]
    powerset xs = filterM (\x -> [True, False]) xs
