import Data.Bits ((.&.))

main = do
    n <- read <$> getLine
    list <- (fmap read . words) <$> getLine
    putStrLn $ show $ solve n 1 0 list 0

solve :: Int -> Int -> Int -> [Int] -> Int -> Int
solve 0 r bsum numls ac = ac
solve l r bsum numls ac
    | length numls>=r = do
        let target = numls!!(r-1)
        case bsum.&.target==0 of
            True -> solve l (r+1) (bsum+target) numls (ac+r)
            False -> shiftL
    | otherwise = shiftL
        where
            shiftL = solve (l-1) (r-1) (bsum-head numls) (drop 1 numls) ac
