405955: GYM102191 F Sum then Multiply
Description
You are given an array of n positive integers. You want to divide the array into one or more parts, where each part is a subarray of the original array. Every integer must be included in exactly one part. After that, you will get the sum of each part, then multiply all the sums together.
For example, the array [8, 1, 1, 3] can be divided into parts [8], [1, 1], and [3], with sums 8, 2, and 3, respectively, giving a product of 48. Note that each part consists of consecutive elements of the array.
Divide the given array in a way that maximizes the final product.
InputThe first line of input contains a single integer n (1 ≤ n ≤ 3 × 105), the size of the array.
The second line of input contains n integers ai (1 ≤ ai ≤ 109), where ai is the ith integer in the array.
OutputPrint exactly one line; the line must contain the input succession a1, a2, ... an divided into parts such that the product of the sums of each part is maximized. Use the slash character ('/') to separate the parts. Separate numbers and slashes with a single space.
If there are multiple solutions, print any of them.
ExamplesInput4 8 1 1 3Output
8 / 1 1 / 3Input
3 1 1 1Output
1 1 1