import Data.List (foldl', find)
import Data.Bits (shiftL, (.|.), testBit)

main = do
  _ <- getLine  
  a <- map read . words <$> getLine
  let f = foldl' (\a x -> a .|. shiftL a x) 1 a :: Integer
  let s = sum a

  let (Just ans) = find (\x -> testBit f x) [(s + 1) `div` 2 ..]
  print ans

