n = int(input())
N = input()
num = 0
while N[num] == ')':
    N = '(' + N
    num += 2
    if num >= n*2:
        break
a = N.count('(')
b = len(N) - a
if (a - b) < 0:
    for i in range(b-a):
        N = '(' + N
elif (a -b) > 0:
    for i in range(a-b):
        N = N + ')'

print(N)