import Data.Bits

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

solve :: Int -> Int -> [Int] -> Int -> Int
solve 0 r nums ac = ac
solve l r nums@(_:rest) ac
    | calc (take r nums) && length nums>=r = solve l (r+1) nums (ac+1)
    | otherwise                            = solve (l-1) 1 rest  ac

calc :: [Int] -> Bool
calc xs = foldl (+) 0 xs == foldl (.|.) 0 xs