{-# LANGUAGE BangPatterns #-} import Data.IORef import qualified Data.Vector.Fusion.Stream.Monadic as VFSM modulo :: Int modulo = 1000000007 main :: IO () main = do n <- readLn :: IO Int ret <- newIORef (1 :: Int) rev n $ \i -> modifyIORef' ret (\x -> (x * ((2 * i - 1) `mod` modulo * i `mod` modulo) `mod` modulo) `mod` modulo) print =<< readIORef ret streamR :: Monad m => Int -> Int -> VFSM.Stream m Int streamR !l !r = VFSM.Stream step r where step x | x >= l = return $ VFSM.Yield x (x - 1) | otherwise = return $ VFSM.Done {-# INLINE [0] step #-} {-# INLINE [1] streamR #-} rev :: Monad m => Int -> (Int -> m ()) -> m () rev n = flip VFSM.mapM_ (streamR 1 n) {-# INLINE rev #-}