import qualified Data.ByteString.Char8 as SC import qualified Data.ByteString.Lazy.Char8 as LC import Data.Maybe (fromJust) unsafeReadInt :: LC.ByteString -> Int unsafeReadInt = fst . fromJust . LC.readInt computeMaxNum :: Int -> SC.ByteString computeMaxNum n | even n = SC.replicate d '1' | otherwise = SC.cons '7' $ SC.replicate (d - 1) '1' where d = div n 2 main :: IO () main = SC.putStrLn . computeMaxNum . unsafeReadInt =<< LC.getContents