An efficient nonconvex reformulation of stagewise convex optimization problems