getMaxNum :: Int -> String getMaxNum n | even n = concat $ replicate d "1" | otherwise = (:) '7' $ concat $ replicate (d - 1) "1" where d = div n 2 main = putStrLn . getMaxNum =<< readLn