Simplify sum and prod.