rewrite sum product