import Control.Applicative import Data.List import Data.Array solve ws = go ws arr where arr = listArray ((0,0),(length ws, sum ws `div` 2 + 1)) $ True : repeat False check m = (/= []) $ filter (\((_,w),v) -> 2 * w == sum ws && v == True) $ assocs m go [] m = check m go (x:xs) m | check m = True | otherwise = let m' = accum (||) m $ filter (\((k,w),_) -> 2 * w <= sum ws) $ fmap (\((k,w),v) -> ((k+1,w+x),v)) $ filter (\(_,v) -> v == True) $ assocs m in go xs m' main = do _ <- getLine ws <- fmap (read :: String -> Int) . words <$> getLine print $ solve $ sortBy (\x y -> compare y x) $ ws