import Data.Bits
import Data.List

solve :: [Int] -> Int
solve xs = length xs + sum (map p (tails xs))
  where p xs = length (takeWhile (\(x,y) -> x .&. y == 0) (zip (scanl1 (+) xs) (tail xs)))

main :: IO ()
main = do
  _n <- getLine
  as <- map read . words <$> getLine
  print $ solve as
