import Control.Applicative ((<$>)) import Control.Monad (forM_, when) import Control.Monad.State (execState, get, modify) import Data.Bits (xor) import Data.Set (fromList, insert, notMember, Set, size) main :: IO () main = do _ <- getLine switches <- map (read :: String -> Int) . words <$> getLine let numbers = (`execState` (fromList [0] :: Set Int)) $ do forM_ switches $ \i -> do ns <- get when (notMember i ns) $ do forM_ ns $ \j -> modify $ insert $ xor i j print $ size numbers