module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A
import Data.Bits

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[]) . show

solver (n:as) = patterns 0 0 as as

-- n <= 20
conb2 n = n * (n+1) `div` 2

patterns len sm [] _ = conb2 len
patterns len sm (a:as) (b:bs)
  = if (sm .&. a) > 0 then len + patterns (len-1) (sm-b) (a:as) bs
                      else patterns (len+1) (sm+a) as (b:bs)


