import Control.Monad import qualified Data.ByteString.Char8 as BSC8 import Data.IORef import Data.Maybe import qualified Data.Vector.Unboxed.Mutable as VUM main :: IO () main = do getLine ax <- getIntList -- ans = 0 p = 1 f = 2 dp <- VUM.replicate 3 (0 :: Int) forM_ ax $ \a -> do p <- VUM.unsafeRead dp 1 f <- VUM.unsafeRead dp 2 if a == p then do VUM.unsafeModify dp succ 0 VUM.unsafeWrite dp 2 1 else if f /= 0 then do VUM.unsafeWrite dp 1 0 VUM.unsafeWrite dp 2 0 else do VUM.unsafeModify dp succ 0 VUM.unsafeWrite dp 2 1 VUM.unsafeWrite dp 1 a print =<< VUM.unsafeRead dp 0 readInt :: BSC8.ByteString -> Int readInt = fst . fromJust . BSC8.readInt {-# INLINE readInt #-} getInt :: IO Int getInt = readInt <$> BSC8.getLine {-# INLINE getInt #-} readIntList :: BSC8.ByteString -> [Int] readIntList = map readInt . BSC8.words {-# INLINE readIntList #-} getIntList :: IO [Int] getIntList = readIntList <$> BSC8.getLine {-# INLINE getIntList #-}