main = getLine >>= print . sum . map (sum . map read) . divides

divides :: [a] -> [[[a]]]
divides [] = []
divides [x] = [[[x]]]
divides (x:xs) = let dxs = divides xs in map ([x] :) dxs ++ map (\(ys:yss) -> (x:ys):yss) dxs