import numpy as np

n = int(eval(input()))

s = list(eval(input()))

j = []

now = 0

unclosen = 0

opened = 0

for i in s:

    if i == ")":

        now -= 1

        if opened:

            opened -= 1

        else:

            unclosen += 1

    else:

        now += 1

        opened += 1

j = np.array(j)

print(("(" * unclosen + "".join(s) + ")" * opened))
n = int(eval(input()))

s = list(eval(input()))

now = 0

unclosen = 0

opened = 0

for i in s:

    if i == ")":

        now -= 1

        if opened:

            opened -= 1

        else:

            unclosen += 1

    else:

        now += 1

        opened += 1

print(("(" * unclosen + "".join(s) + ")" * opened))
import numpy as np

n = int(eval(input()))
s = list(eval(input()))
j = []
now = 0
unclosen = 0
opened = 0
for i in s:
    if i == ")":
        now -= 1
        if opened:
            opened -= 1
        else:
            unclosen += 1
    else:
        now += 1
        opened += 1
j = np.array(j)
print(("(" * unclosen + "".join(s) + ")" * opened))

n = int(eval(input()))
s = list(eval(input()))
now = 0
unclosen = 0
opened = 0
for i in s:
    if i == ")":
        now -= 1
        if opened:
            opened -= 1
        else:
            unclosen += 1
    else:
        now += 1
        opened += 1
print(("(" * unclosen + "".join(s) + ")" * opened))

-import numpy as np - -j = [] -j = np.array(j)