405955: GYM102191 F Sum then Multiply

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Sum then Multiplytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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.

Input

The 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.

Output

Print 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.

ExamplesInput
4
8 1 1 3
Output
8 / 1 1 / 3 
Input
3
1 1 1
Output
1 1 1 

加入题单

算法标签: