sum with foldl and foldr implemented