import Data.Bits ((.&.))
import Data.Array.IO(IOArray,newListArray,readArray)

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

solve :: Int -> Int -> Int -> Int -> IOArray Int Int -> Int -> IO Int
solve lim l r bsum arr ac
    | l>lim  = return ac
    | lim>=r = do
        rVal <- readArray arr r
        case bsum.&.rVal==0 of
            True -> solve lim l (r+1) (bsum+rVal) arr (ac+r-l+1)
            False -> shiftL
    | otherwise = shiftL
        where
            shiftL = do
                lVal <- readArray arr l
                solve lim (l+1) r (bsum-lVal) arr ac