{-# LANGUAGE TypeApplications #-}

-- | E - Multiplication 4
module Main where

import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  (n : k : _) <- map (read @Int) . words <$> getLine
  as <- take k . map (read . BS.unpack) . BS.words <$> BS.getLine
  print $ (product as) `mod` 1000000007
