import Control.Monad import Control.Monad.ST import Data.Bool import qualified Data.Array.ST as ArrST import qualified Data.Array.Unboxed as ArrU sieveUA :: Int -> ArrU.UArray Int Bool sieveUA top = ArrST.runSTUArray $ do let m = (top-1) `div` 2 r = floor . sqrt $ fromIntegral top + 1 sieve <- ArrST.newArray (1,m) True forM_ [1..r `div` 2] $ \i -> do isPrime <- ArrST.readArray sieve i when isPrime $ do forM_ [2*i*(i+1), 2*i*(i+2)+1..m] $ \j -> do ArrST.writeArray sieve j False return sieve primesToUA :: Int -> [Int] primesToUA top = 2 : [i*2+1 | (i,True) <- ArrU.assocs $ sieveUA top] main :: IO () main = readLn >>= putStrLn . solver solver :: Int -> String solver n = bool "NO" "YES" $ func1 n func1 :: Int -> Bool func1 n = iter n 0 ps where ps = primesToUA 10000000 iter _ p [] = p >= 3 iter i j (l:ls) | j >= 3 = True | i `mod` l == 0 = iter i (j + 1) ls | otherwise = iter i j ls