import Control.Monad
import Data.List

main = do
    n <- readLn :: IO Int
    temp <- map read . words <$> getLine :: IO [Int]
    let ns =  sort temp
    let cands = powerSet $ filter (\x -> isPow2 (x !! 0 + x !! 1)) $ comb ns 2
    -- print $ cands
    -- print $ [ getNum cand ns | cand <- cands ]
    print $ maximum $ [ getNum cand ns | cand <- cands ]

isPow2 :: Int -> Bool
isPow2 n
    | n == 1 = True
    | amari == 0 = isPow2 (n `div` 2)
    | amari == 1 = False
    where
        amari = n `mod` 2  

comb :: [a] -> Int -> [[a]]
comb _ 0     = [[]]
comb [] _     = []
comb (x:xs) n = map (x:) (comb xs (n-1)) ++ comb xs n

powerSet :: [a] -> [[a]]
powerSet [] = [[]]
powerSet (x:xs) = [x:ps | ps <- powerSet xs] ++ powerSet xs

getNum :: [[Int]] -> [Int] -> Int
getNum cand ns = if subList (sort . join $ cand) ns then length cand else 0

subList :: Eq a => [a] -> [a] -> Bool
subList [] [] = True
subList _ []    = False
subList [] _    = True
subList (x:xs) (y:ys) 
    | x == y    = subList xs ys   
    | otherwise = subList (x:xs) ys