N = int(input())
S = input()
l = 0
r = 0
for i in range(N):
    if S[i] == ')':
        if r > 0:
            r -= 1
        else:
            l += 1
    else:
        r += 1
for _ in range(l):
    print('(', end='')
print(S, end='')
for _ in range(r):
    print(')', end='')

ef370c08196cfae7ba02dc5c0133c0bb94a6062c
<mask token>

<mask token>
for i in range(N):
    if S[i] == ')':
        if r > 0:
            r -= 1
        else:
            l += 1
    else:
        r += 1
for _ in range(l):
    print('(', end='')
print(S, end='')
for _ in range(r):
    print(')', end='')

N = int(input())
S = input()
l = 0
r = 0
for i in range(N):
    if S[i] == ')':
        if r > 0:
            r -= 1
        else:
            l += 1
    else:
        r += 1
for _ in range(l):
    print('(', end='')
print(S, end='')
for _ in range(r):
    print(')', end='')
