local n=io.read("n","l")
local s=io.read()
local t=s:gsub("%b()","")
local l,r=0,0
for i=1,#t do
    if t:sub(i,i)==")" then
        l=l+1
    else
        r=r+1
    end
end
print(string.rep("(",l)..s..string.rep(")",r))
