{-# LANGUAGE TypeApplications #-}

module Main where

import Control.Monad (filterM)
import qualified Data.ByteString.Char8 as BS
import Data.List (partition, sort, sortOn)
import Data.Ord (Down(Down))
import Data.Bifunctor (Bifunctor(bimap))

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