main :: IO () main = readLn >>= print . solve solve :: Int -> Int solve n = last $ take n $ cycle [2,8,5,7,1,4]