시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB30151565.217%

문제

There are $2n$ elements divided into $n$ pairs.

For each pair, you should either assign an opening bracket to both elements, or closing bracket to both elements. You need to make the resulting sequence of brackets a correct bracket sequence or determine that it is impossible. If there are several possible solutions, find the solution with the smallest lexicographically string (of $2n$ brackets, '(' is smaller than ')').

입력

The first line contains one integer $n$ ($1 \leq n \leq 200\,000$).

The next line contains $2n$ integers, $p_1, p_2, \ldots, p_{2n}$ ($1 \leq p_i \leq n$). All integers from $1$ to $n$ appear exactly two times in this sequence.

출력

If it is impossible to choose one type of bracket for each pair to make the derived bracket sequence correct, print "(" (Russian sad smiley). Otherwise, print the desired lexicographically minimal correct bracket sequence.

예제 입력 1

2
1 2 1 2

예제 출력 1

()()

예제 입력 2

1
1 1

예제 출력 2

(

예제 입력 3

4
4 3 1 2 3 2 1 4

예제 출력 3

(

예제 입력 4

4
3 1 2 1 4 3 2 4

예제 출력 4

(()()())

예제 입력 5

4
2 4 3 1 3 4 2 1

예제 출력 5

()()()()

예제 입력 6

4
4 4 3 3 1 2 1 2

예제 출력 6

(((())))

예제 입력 7

4
1 3 1 2 4 4 2 3

예제 출력 7

()(())()