import Data.Int import Data.List (foldl') import Control.Applicative m = 1000003 getInts :: IO [Int64] getInts = map (fromIntegral . read) . words <$> getLine mod_pow :: Int64 -> Int64 -> Int64 mod_pow a n = helper a bs 1 where helper _ [] r = r helper a (0:bs) r = helper (a*a`mod`m) bs r helper a (1:bs) r = helper (a*a`mod`m) bs (r*a`mod`m) bs = map (`mod`2) . takeWhile (>0) $ iterate (`div`2) n main = do [x, n] <- getInts as <- getInts let f x y = (x + y) `mod` m in print $ foldl' f 0 . map (mod_pow x) $ as