eolymp
bolt
Try our new interface for solving problems
Problems

Asterisk

Asterisk

Time limit 0.5 seconds
Memory limit 64 MiB

Recently Cuckooland mathematicians have invented a new binary operation "asterisk", which uses sequences as its arguments. Operation just appends the first sequence to the second. For example (2, 4) * (1, 3) = (1, 3, 2, 4). "Asterisk" operations in one expression are performed in order from the leftmost to the rightmost, but this order can be changed with brackets (operations in brackets are performed earlier). E. g. (3) * ((1, 5) * (2, 7)) = (2, 7, 1, 5, 3). Notice that if a sequence element is represented by an expression, then this expression is calculated first and then all nested brackets in this sequence are removed. For example, (1, ((2) * (3)), 4) = (1, (3, 2), 4) = (1, 3, 2, 4).

Now cuckoolanders want to use this operation for generating permutations. More precisely, they want to obtain a given permutation from permutation (1, 2, …, N) by adding brackets, commas and asterisks and evaluating the resulting expression.

The formal definition of expression follows.

<expression> ::= <sequence>[*<sequence>…]

<sequence> ::= (<sequence element>[,<sequence element>…])

<sequence element> ::= <number> | <expression>

<number> ::= 1|2|…|N

Input data

The first line contains an integer N (1N10000). The second line contains a permutation of numbers from 1 to N. These numbers are separated by spaces.

Output data

Output a single line — correct expression, the result of which is the given permutation. Numbers from 1 to N should appear in ascending order. The length of the expression should not exceed 100000 symbols. In case there is no such expression output "IMPOSSIBLE". Note that expression must not contain spaces and all sequences must be enclosed in brackets.

Examples

Input example #1
4
3 4 2 1
Output example #1
(((1)*(2))*((3),(4)))
Author Daniil Ayzenshteyn
Source Ural SU Contest. Petrozavodsk Summer Session, August 2008