Flatten multiplication and fold integral constants