{-# LANGUAGE TypeApplications #-}

-- | E - Multiplication 4
module Main where

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