local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, n do t[i] = s:sub(i, i) == "(" and 1 or - 1 end
local mmi = math.min
while true do
  local minval = 0
  local curval = 0
  for i = 1, n do
    curval = curval + t[i]
    minval = mmi(minval, curval)
  end
  if minval < 0 then
    for i = 1, -minval do
      table.insert(t, 1, 1)
    end
    n = n - minval
  elseif 0 < curval then
    for i = 1, curval do
      table.insert(t, -1)
    end
    n = n + curval
  else
    break
  end
end
for i = 1, n do
  t[i] = t[i] == 1 and "(" or ")"
end
print(table.concat(t))
