


Minuses
The operation of subtraction is not associative, e.g. (52)1=2, but 5(21)=4, therefore (52)1<>5(21). It implies that the value of the expression of the form 521 depends on the order of performing subtractions. In lack of brackets we assume that the operations are performed from left to right, i.e. the expression 521 denotes (52)1. We are given an expression of the form x_{1} +/ x_{2} +/ ... +/ x_{n}, where each +/ denotes either + (plus) or  (minus), and x_{1},x_{2},...,x_{n} denote (pairwise) distinct variables. In an expression of the form x_{1}x_{2}...x_{n} we want to insert brackets in such a way as to obtain an expression equivalent to the given one. For example, if we want to obtain an expression equivalent to the expression x_{1}x_{2}x_{3}+x_{4}+x_{5}x_{6}+x_{7} we may insert brackets into x_{1}x_{2}x_{3}x_{4}x_{5}x_{6}x_{7} as follows: ((x_{1}x_{2})(x_{3}x_{4}x_{5}))(x_{6}x_{7}). Note: Brackets that surround none or only one variable are not allowed. TaskWrite a program which:
InputIn the first line of the text file min.in there is one integer n, 2<=n<=1 000 000. This is the number of variables in the given expression. In each of the following n1 lines there is one character + or . In the ith line there is the sign appearing between x_{i1} and x_{i} in the given expression.OutputIn the first line of the output text file min.out your program should write the requested way of bracket insertion into the expression x_{1}x_{2}...x_{n}. Only brackets and minuses (without spaces between them) should be written, and the variables x_{1},x_{2},...,x_{n} ought to be skipped. You may assume that for the test data there is always a solution. If there exist many possible solutions your program should write one of them.ExampleFor the following input file min.in:7   + +  +a correct answer is in the following output file min.out: (()())() Print friendly version 