Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.

In his favorite math class, the teacher taught him the following interesting definitions.

A parenthesis sequence is a string, containing only characters "(" and ")".

A correct parenthesis sequence is a parenthesis sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, parenthesis sequences "()()", "(())" are correct (the resulting expressions are: "(1+1)+(1+1)", "((1+1)+1)"), while ")(" and ")" are not. Note that the empty string is a correct parenthesis sequence by definition.

We define that $|s|$ as the length of string $s$. A strict prefix $s[1\dots l]$ $(1\leq l< |s|)$ of a string $s = s_1s_2\dots s_{|s|}$ is string $s_1s_2\dots s_l$. Note that the empty string and the whole string are not strict prefixes of any string by the definition.

Having learned these definitions, he comes up with a new problem. He writes down a string $s$ containing only characters "(", ")" and "?". And what he is going to do, is to replace each of the "?" in $s$ independently by one of "(" and ")" to make all strict prefixes of the new sequence not a correct parenthesis sequence, while the new sequence should be a correct parenthesis sequence.

After all, he is just a primary school student so this problem is too hard for him to solve. As his best friend, can you help him to replace the question marks? If there are many solutions, any of them is acceptable.


-----Input-----

The first line contains a single integer $|s|$ ($1\leq |s|\leq 3 \cdot 10^5$), the length of the string.

The second line contains a string $s$, containing only "(", ")" and "?".


-----Output-----

A single line contains a string representing the answer.

If there are many solutions, any of them is acceptable.

If there is no answer, print a single line containing ":(" (without the quotes).


-----Examples-----
Input
6
(?????

Output
(()())
Input
10
(???(???(?

Output
:(



-----Note-----

It can be proved that there is no solution for the second sample, so print ":(".

Difficulty: MEDIUM_HARD
Tags: String algorithms

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
ans = []
count = 0
for i in s:
	if i == '(':
		ans.append(1)
	elif i == ')':
		ans.append(-1)
	else:
		ans.append(0)
		count += 1
x = sum(ans)
if abs(x) > count or x % 2 != count % 2:
	print(':(')
	exit()
hi = (x + count) // 2
mi = count - hi
for i in range(n):
	if ans[i] == 0 and mi:
		ans[i] = 1
		mi -= 1
	elif ans[i] == 0:
		ans[i] = -1
rui = [0] * (n + 1)
for i in range(n):
	rui[i + 1] = rui[i] + ans[i]
	if rui[i + 1] <= 0 and i != n - 1:
		print(':(')
		exit()
	if ans[i] == 1:
		ans[i] = '('
	else:
		ans[i] = ')'
print(''.join(ans))


_DEBUG = True
n = int(input())
s = input()

def solve(s):
	ns = list(s)
	l = len(ns)
	lc = rc = 0
	for e in s:
		if e == '(':
			lc += 1
		elif e == ')':
			rc += 1
	l_stack = 0
	for i in range(l):
		e = s[i]
		if e == '(':
			l_stack += 1
		elif e == ')':
			l_stack -= 1
		elif lc < l // 2:
			ns[i] = '('
			l_stack += 1
			lc += 1
		else:
			ns[i] = ')'
			l_stack -= 1
			rc += 1
		if i != l - 1 and l_stack <= 0:
			return None
	return ''.join(ns) if l_stack == 0 else None
res = solve(s)
if res is None:
	print(':(')
else:
	print(res)


length = int(input())
string = input()
LeftParens = 0
questionMarks = 0
imposs = False
moreLeftAndQ = 0
moreRightAndQBack = 0
if length % 2 == 1:
	imposs = True
for i in range(length - 1):
	if string[i] == '(':
		LeftParens += 1
		moreLeftAndQ += 1
	elif string[i] == ')':
		moreLeftAndQ -= 1
		if moreLeftAndQ < 1:
			imposs = True
			break
	else:
		moreLeftAndQ += 1
	if string[length - i - 1] == '(':
		moreRightAndQBack -= 1
		if moreRightAndQBack < 1:
			imposs = True
			break
	elif string[length - i - 1] == ')':
		moreRightAndQBack += 1
	else:
		moreRightAndQBack += 1
if imposs:
	print(':(')
else:
	newString = ''
	for i in range(length):
		if string[i] == '?':
			if length / 2 - LeftParens > 0:
				newString = newString + '('
				LeftParens += 1
			else:
				newString = newString + ')'
		else:
			newString = newString + string[i]
	print(newString)


import sys
num = int(input())
raw = input()
inputs = [item for item in raw]
result = [item for item in raw]
if num % 2 == 0:
	found = True
	a = 0
	b = 0
	c = 0
	for i in range(num):
		if inputs[i] == '(':
			a += 1
		elif inputs[i] == ')':
			b += 1
		else:
			c += 1
	if (abs(a - b) + c) % 2 != 0 or a - b + c < 0 or b - a + c < 0:
		print(':(')
	else:
		if a > b:
			n = a - b
			for i in range(num - 1, 0, -1):
				if n == 0:
					break
				if inputs[i] == '?':
					inputs[i] = ')'
					n -= 1
		elif a < b:
			n = b - a
			for i in range(0, num):
				if n == 0:
					break
				if inputs[i] == '?':
					inputs[i] = '('
					n -= 1
		n = (c - abs(a - b)) / 2
		for i in range(0, num):
			if n == 0:
				break
			if inputs[i] == '?':
				inputs[i] = '('
				n -= 1
		n = (c - abs(a - b)) / 2
		for i in range(num - 1, 0, -1):
			if n == 0:
				break
			if inputs[i] == '?':
				inputs[i] = ')'
				n -= 1
		sum = (inputs[0] == '(') - (inputs[0] == ')')
		temp = 0
		for i in range(1, num - 1):
			sum = sum + (inputs[i] == '(') - (inputs[i] == ')')
			if sum <= 0:
				print(':(')
				sys.exit(0)
		print(''.join(inputs))
else:
	print(':(')


n = int(input())
s = input()
l = list(s)
(count, count1) = (0, 0)
if n % 2 == 1:
	print(':(')
	exit()
for i in range(n):
	if s[i] == '(':
		count += 1
	elif s[i] == ')':
		count1 += 1
count = n // 2 - count
for j in range(n):
	if s[j] == '?' and count > 0:
		l[j] = '('
		count -= 1
	elif s[j] == '?':
		l[j] = ')'
m = ''.join(l)
count1 = 0
count = 0
if m[0] == ')' or m[n - 1] == '(':
	print(':(')
	exit()
for k in range(n):
	if m[k] == '(':
		count += 1
	else:
		count1 += 1
	if count == count1 and count != n / 2:
		print(':(')
		exit()
if count == n / 2:
	print(m)
else:
	print(':(')


n = int(input())
s = input()
fail = ':('
if n % 2 != 0:
	print(fail)
	quit()
ocount = n // 2 - s.count('(')
ccount = n // 2 - s.count(')')
ans = []
balance = 0
for (i, sym) in enumerate(s):
	if sym != '?':
		ans.append(sym)
	elif ocount > 0:
		ocount -= 1
		ans.append('(')
	elif ccount > 0:
		ccount -= 1
		ans.append(')')
	else:
		raise Exception
	x = ans[-1]
	if x == '(':
		balance += 1
	else:
		balance -= 1
	if balance < 0:
		print(fail)
		quit()
	elif i < n - 1 and balance == 0:
		print(fail)
		quit()
if balance != 0:
	print(fail)
	quit()
else:
	print(''.join(ans))


N = int(input())
S = input()
l = 0
r = 0
for s in S:
	if s == '(':
		l += 1
	elif s == ')':
		r += 1
if N % 2 == 1:
	ans = ':('
else:
	lim = N // 2
	ok = True
	if l > lim or r > lim:
		ok = False
	ans = ''
	for s in S:
		if s == '(' or s == ')':
			ans += s
		elif l < lim:
			ans += '('
			l += 1
		else:
			ans += ')'
	d = 0
	for i in range(N - 1):
		a = ans[i]
		if a == '(':
			d += 1
		elif d > 1:
			d -= 1
		else:
			ok = False
	if not ok:
		ans = ':('
print(ans)


from collections import *
from math import *
n = int(input())
s = list(input())
ct = s.count('(')
for i in range(n):
	if s[i] == '?':
		if ct < n // 2:
			s[i] = '('
			ct += 1
		else:
			s[i] = ')'
ct = 0
for i in range(n):
	if s[i] == '(':
		ct += 1
	else:
		ct -= 1
	if ct == 0 and i != n - 1:
		print(':(')
		break
	elif ct != 0 and i == n - 1:
		print(':(')
		break
	if ct < 0:
		print(':(')
		break
else:
	for i in range(n):
		print(s[i], end='')
	print()


def main():
	n = int(input())
	s = list(input())
	temp_count = 0
	for c in s:
		if c == '(':
			temp_count += 1
	stack = []
	for i in range(n):
		if i == n - 1 and (len(stack) != 1 or s[i] == '('):
			print(':(')
			return
		if s[i] == '(':
			stack.append(s[i])
		elif s[i] == ')':
			if not stack:
				print(':(')
				return
			stack.pop()
		elif i != n - 1 and temp_count < n // 2:
			s[i] = '('
			stack.append('(')
			temp_count += 1
		else:
			s[i] = ')'
			stack.pop()
		if i != n - 1 and (not stack):
			print(':(')
			return
	print(''.join(s))

def __starting_point():
	main()
__starting_point()


n = int(input())
l = list(input())
if n % 2 == 1:
	print(':(')
	exit()
if n == 2:
	if l[0] == ')' or l[1] == '(':
		print(':(')
	else:
		print('()')
	exit()
if l[0] == ')' or l[1] == ')' or l[-1] == '(' or (l[-2] == '('):
	print(':(')
	exit()
l[0] = '('
l[1] = '('
l[-1] = ')'
l[-2] = ')'
p = l.count(')') - l.count('(')
q = l.count('?')
a = (q + p) // 2
b = q - a
cnt = 0
for i in range(len(l)):
	if l[i] == '?':
		if cnt < a:
			l[i] = '('
		else:
			l[i] = ')'
		cnt += 1
cnt = 0
for (p, i) in enumerate(l):
	if i == '(':
		cnt += 1
	else:
		cnt -= 1
	if cnt == 0 and p != n - 1:
		print(':(')
		exit()
else:
	if cnt != 0:
		print(':(')
		exit()
print(''.join(l))


n = int(input())
s = list(input())
if n % 2:
	print(':(')
	exit()
left = s.count('(')
right = s.count(')')
plus = 0
for i in range(n):
	if s[i] == '?':
		if left < n // 2:
			s[i] = '('
			left += 1
		else:
			s[i] = ')'
			right += 1
	if s[i] == '(':
		plus += 1
	else:
		plus -= 1
	if i != n - 1 and plus <= 0:
		print(':(')
		exit()
if left == n // 2 and right == n // 2:
	print(''.join(s))
else:
	print(':(')


n = int(input())
s = list(input())
b = s.count('(') - s.count(')')
undef = s.count('?')
if b != 0 and undef == 0 or b > undef:
	print(':(')
	exit()
if b >= 0:
	nClose = b
	undef -= nClose
	if undef & 1 == 1:
		print(':(')
		exit()
	nOpen = undef >> 1
	nClose += nOpen
else:
	if undef + b < 0:
		print(':(')
		exit()
	nOpen = -b
	undef -= nOpen
	if undef & 1 == 1:
		print(':(')
		exit()
	nClose = undef >> 1
	nOpen += nClose
b = 0
for i in range(n):
	if s[i] == '(':
		b += 1
	elif s[i] == ')':
		b -= 1
	elif nOpen > 0:
		s[i] = '('
		nOpen -= 1
		b += 1
	else:
		s[i] = ')'
		nClose -= 1
		b -= 1
	if i < n - 1 and b <= 0:
		print(':(')
		exit()
print(''.join(s))


n = int(input())
a = list(input())
if n % 2:
	print(':(')
	exit(0)
cnt = 0
osc = a.count('(')
ans = osc <= n // 2
for i in range(len(a)):
	if a[i] == '?':
		if osc == n // 2:
			a[i] = ')'
			cnt -= 1
		else:
			a[i] = '('
			cnt += 1
			osc += 1
	elif a[i] == '(':
		cnt += 1
	else:
		cnt -= 1
	if cnt <= 0 and i != len(a) - 1:
		ans = False
if ans:
	for i in a:
		print(i, end='')
elif not ans or cnt != 0:
	print(':(')


n = int(input())
data = list(input())
if data[0] == ')' or data[-1] == '(':
	print(':(')
	exit(0)
now = 0
data[0] = '('
data[-1] = ')'
haveO = (n - 2) // 2
haveC = (n - 2) // 2
for i in range(1, n - 1):
	if data[i] == '(':
		haveO -= 1
	elif data[i] == ')':
		haveC -= 1
for i in range(1, n - 1):
	if data[i] == '?':
		if haveO:
			haveO -= 1
			data[i] = '('
		else:
			data[i] = ')'
now = 0
fl = True
for i in range(0, n):
	if data[i] == '(':
		now += 1
	elif data[i] == ')':
		now -= 1
	if now < 0:
		fl = False
	if now == 0 and i != n - 1:
		fl = False
if fl and now == 0:
	print(*data, sep='')
else:
	print(':(')


import sys
input = sys.stdin.readline
n = int(input())
s = list(input().strip())
if n % 2 == 1:
	print(':(')
	return
if n == 2:
	if s[0] == ')' or s[1] == '(':
		print(':(')
		return
	else:
		print('()')
		return
if s[0] == ')' or s[1] == ')' or s[-1] == '(' or (s[-2] == '('):
	print(':(')
	return
s[0] = '('
s[1] = '('
s[-1] = ')'
s[-2] = ')'
r = s.count('(')
l = s.count(')')
q = s.count('?')
x = (l - r + q) // 2
y = (r - l + q) // 2
if x < 0 or y < 0:
	print(':(')
	return
count = 0
for i in range(n):
	if s[i] == '?':
		s[i] = '('
		count += 1
	if count == x:
		break
for j in range(i, n):
	if s[j] == '?':
		s[j] = ')'
NOW = 1
for i in range(1, n - 1):
	if s[i] == '(':
		NOW += 1
	else:
		NOW -= 1
	if NOW == 0:
		print(':(')
		return
print(''.join(s))


n = int(input())
s = list(input())
(a, b) = (s.count('('), 0)
for i in range(n):
	if s[i] == '?':
		if a < n // 2:
			s[i] = '('
			a += 1
		else:
			s[i] = ')'
	if s[i] == '(':
		b += 1
	else:
		b -= 1
	if b < 0 or (b == 0 if i + 1 != n else b != 0):
		print(':(')
		exit(0)
print(''.join(s))


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
from copy import deepcopy
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))
n = inp()
s = list(sys.stdin.readline())
s = s[:n]
if n % 2:
	print(':(')
	quit()
d = {'(': 1, '?': 0, ')': -1}
rd = {1: '(', -1: ')'}
a = [d[x] for x in s]
ca = list(itertools.accumulate(a))
p = a.count(1)
q = a.count(-1)
if p > n // 2 or q > n // 2:
	print(':(')
	quit()
P = n // 2 - p
Q = n // 2 - q
for (i, x) in enumerate(a):
	if P == 0:
		break
	if x == 0:
		a[i] = 1
		P -= 1
for i in range(n)[::-1]:
	if Q == 0:
		break
	if a[i] == 0:
		a[i] = -1
		Q -= 1
ca = list(itertools.accumulate(a))
if min(ca) < 0 or ca.count(0) > 1:
	print(':(')
	quit()
for i in range(n):
	a[i] = rd[a[i]]
print(''.join(a))


n = int(input())
s = input()
open = 0
closed = 0
for i in range(n):
	if s[i] == '(':
		open += 1
	elif s[i] == ')':
		closed += 1
a = n / 2 - open
b = n / 2 - closed
ans = ''
openct = 0
closedct = 0
can = True
if n % 2 or open > n / 2:
	can = False
	can = False
if can:
	for i in range(n):
		if s[i] == '?':
			if a:
				openct += 1
				ans += '('
				a -= 1
			else:
				closedct += 1
				ans += ')'
		elif s[i] == '(':
			ans += '('
			openct += 1
		elif s[i] == ')':
			ans += ')'
			closedct += 1
		if i != n - 1:
			if closedct >= openct:
				can = False
				break
if can:
	print(ans)
else:
	print(':(')


n = int(input())
s = input()
l = s.count('(')
r = s.count(')')
ans = '('
x = ':('
if n & 1 or l > n // 2 or r > n // 2:
	print(x)
else:
	l1 = n // 2 - l
	r1 = n // 2 - r
	(l, r) = (0, 0)
	ans = ''
	i = 0
	while i < len(s):
		if s[i] == '?':
			if l1 > 0:
				ans += '('
				l += 1
				l1 -= 1
			else:
				ans += ')'
				r += 1
				r1 -= 1
		elif s[i] == '(':
			l += 1
			ans += '('
		else:
			r += 1
			ans += ')'
		if r >= l and i != len(s) - 1:
			ans = ':('
			break
		i += 1
	print(ans)


import sys
n = int(input())
raw = input()
st = [item for item in raw]
if n & 1:
	print(':(')
	sys.exit()
left = st.count('(')
if left > n // 2:
	print(':(')
	sys.exit(0)
if st[0] == '?':
	st[0] = '('
if st[len(st) - 1] == '?':
	st[len(st) - 1] = ')'
le = 0
if st[0] == '(' and st[len(st) - 1] == ')':
	left = st.count('(')
	lagbo = n // 2 - left
	for i in range(1, len(st) - 1):
		n -= 2
		if st[i] == '?':
			if lagbo > 0:
				st[i] = '('
				lagbo -= 1
			else:
				st[i] = ')'
		if st[i] == '(':
			le += 1
		else:
			le -= 1
		if le < 0:
			print(':(')
			sys.exit()
	if le == 0:
		print(''.join(st))
	else:
		print(':(')
else:
	print(':(')


n = int(input())
s = input()
x = []
res = []
(o1, c1) = (0, 0)
for i in s:
	x.append(i)
	if i == '(':
		o1 += 1
	elif i == ')':
		c1 += 1
if n % 2:
	print(':(')
elif x[0] == ')' or x[n - 1] == '(':
	print(':(')
else:
	(o, c) = (n / 2 - o1, n / 2 - c1)
	(o2, c2) = (0, 0)
	for i in range(n):
		if x[i] == '?':
			if o > 0:
				res.append('(')
				o -= 1
				o1 += 1
				o2 += 1
			else:
				res.append(')')
				c -= 1
				c1 += 1
				c2 += 1
		else:
			res.append(x[i])
			if x[i] == '(':
				o2 += 1
			else:
				c2 += 1
		if i != n - 1 and c2 == o2:
			break
	if c2 == o2 and c2 + o2 == n:
		for i in range(n):
			print(res[i], end='')
	else:
		print(':(')


n = int(input())
s = input().strip()
if n % 2 != 0:
	print(':(')
	exit()
upper = 0
uppers = []
lower = 0
for c in s[:-1]:
	if c == '(':
		upper += 1
		lower += 1
	elif c == ')':
		upper -= 1
		lower -= 1
		if upper <= 0:
			print(':(')
			exit()
	else:
		upper += 1
		lower -= 1
	if lower == 0:
		lower = 2
	if lower == -1:
		lower = 1
	uppers.append(upper)
if lower != 1:
	print(':(')
	exit()
if s[-1] == '(':
	print(':(')
	exit()
arr = [')']
height = 1
for i in range(n - 2, 0, -1):
	if s[i] == '(':
		arr.append('(')
		height -= 1
	elif s[i] == ')':
		arr.append(')')
		height += 1
	elif uppers[i - 1] >= height + 1:
		arr.append(')')
		height += 1
	else:
		arr.append('(')
		height -= 1
print('(' + ''.join(reversed(arr)))


l = int(input())
s = list(input())
count = s.count('(')
pair_count = 0
if l % 2 != 0:
	print(':(')
	exit(0)
if count > l // 2:
	print(':(')
	exit(0)
for ind in range(l):
	if s[ind] == '?':
		if count < l // 2:
			s[ind] = '('
			count += 1
		else:
			s[ind] = ')'
	if s[ind] == '(':
		pair_count += 1
	if s[ind] == ')':
		pair_count -= 1
	if pair_count <= 0 and ind + 1 != l:
		print(':(')
		exit(0)
print(''.join(s))


n = int(input())
s = list(input())
(o, c) = (s.count('('), s.count(')'))
for i in range(n):
	if s[i] == '?':
		if 2 * o >= n:
			s[i] = ')'
		else:
			o += 1
			s[i] = '('
sum = 0
for i in range(n):
	sum += 1 if s[i] == '(' else -1
	if i < n - 1 and sum < 1:
		print(':(')
		exit()
	if i == n - 1 and sum != 0:
		print(':(')
		exit()
print(''.join(s))


n = int(input())
s = list(input())
l = s.count('(')
r = s.count(')')
for i in range(n):
	if s[i] == '?':
		if 2 * l < n:
			l += 1
			s[i] = '('
		else:
			s[i] = ')'
cnt = 0
for i in range(n):
	cnt += 1 if s[i] == '(' else -1
	if i < n - 1 and cnt < 1:
		print(':(')
		exit()
	if i == n - 1 and cnt != 0:
		print(':(')
		exit()
print(''.join(s))


n = int(input())
s = list(input())
if n == 0:
	print('')
	exit()
if s[0] == ')' or s[-1] == '(':
	print(':(')
	exit()
if n % 2 != 0:
	print(':(')
	exit()
q_marks_count = 0
l_brackets_count = 0
r_brackets_count = 0
for i in range(n):
	if s[i] == '?':
		q_marks_count += 1
	elif s[i] == '(':
		l_brackets_count += 1
	else:
		r_brackets_count += 1
need_l = max(r_brackets_count - l_brackets_count, 0)
need_r = max(l_brackets_count - r_brackets_count, 0)
q_marks_last = q_marks_count - max(need_l, need_r)
if q_marks_last < 0:
	print(':(')
	exit()
half = q_marks_last // 2
need_l += half
need_r += half
level = 0
for i in range(n):
	if s[i] == '?':
		if need_l > 0:
			s[i] = '('
			need_l -= 1
		elif need_r > 0:
			s[i] = ')'
			need_r -= 1
	if s[i] == '(':
		level += 1
	if s[i] == ')':
		level -= 1
	if level <= 0 and i != n - 1:
		print(':(')
		exit()
print(''.join(s))


n = int(input())
s = list(input())

def create_seq(n, s):
	if n % 2 == 1:
		return print(':(')
	if s[0] == ')':
		return print(':(')
	open_limit = int(n / 2)
	close_limit = int(n / 2)
	for i in range(n):
		if s[i] == '(':
			open_limit -= 1
		elif s[i] == ')':
			close_limit -= 1
	cnt_left = 0
	cnt_right = 0
	flg = 0
	if (open_limit < 0) | (close_limit < 0):
		flg = 1
	for i in range(n):
		if (cnt_left - cnt_right == 0) & (i > 0):
			flg = 1
			break
		if (s[i] == '?') & (i == 0):
			s[i] = '('
			cnt_left += 1
			open_limit -= 1
		elif s[i] == '(':
			cnt_left += 1
		elif s[i] == ')':
			cnt_right += 1
		elif cnt_left - cnt_right >= 1:
			if open_limit > 0:
				s[i] = '('
				cnt_left += 1
				open_limit -= 1
			elif close_limit > 0:
				s[i] = ')'
				cnt_right += 1
				close_limit -= 1
		elif cnt_left - cnt_right > 1:
			if close_limit > 0:
				s[i] = ')'
				cnt_right += 1
				close_limit -= 1
			elif open_limit > 0:
				s[i] = '('
				cnt_left += 1
				open_limit -= 1
	if flg == 1:
		return print(':(')
	else:
		return print(''.join(s))
create_seq(n, s)


from sys import exit
from itertools import accumulate
N = int(input())
S = input()
if S[0] == ')' or S[-1] == '(' or N % 2 == 1:
	print(':(')
	exit()
L = [0] * N
posi = 0
nega = 0
for (i, s) in enumerate(S):
	if s == '(':
		posi += 1
		L[i] = 1
		continue
	elif s == ')':
		nega += 1
		L[i] = -1
		continue
rem = N - posi - nega
sp = nega - posi
pi = (rem + sp) // 2
ni = (rem - sp) // 2
if pi < 0 or ni < 0:
	print(':(')
	exit()
LP = L.copy()
for (i, a) in enumerate(L):
	if not a:
		if pi > 0:
			pi -= 1
			LP[i] = 1
		else:
			LP[i] = -1
if all([i > 0 for i in list(accumulate(LP))[:-1]]):
	print(''.join([('', '(', ')')[l] for l in LP]))
	exit()
print(':(')


def main():
	n = int(input())
	s = input()
	mid = s[1:len(s) - 1]
	if n == 1:
		print(':(')
		return
	correct = False
	left = 0
	right = 0
	for i in mid:
		if i == '(':
			left += 1
		elif i == ')':
			right += 1
	left = len(mid) // 2 - left
	right = len(mid) // 2 - right
	new = ''
	for i in mid:
		if i == '?':
			if left != 0:
				new += '('
				left -= 1
			elif right != 0:
				new += ')'
				right -= 1
			else:
				print(':(')
				return
		else:
			new += i
	left = 0
	for i in new:
		if i == '(':
			left += 1
		elif left > 0:
			left -= 1
		else:
			print(':(')
			return
	if left > 0:
		print(':(')
		return
	if (s[0] == '(' or s[0] == '?') and (s[-1] == ')' or s[-1] == '?'):
		new = '(' + new
		new += ')'
	else:
		print(':(')
		return
	print(new)
main()


import math

def is_correct(pattern):
	opened = 0
	for i in range(len(pattern)):
		if pattern[i] == '(':
			opened += 1
		else:
			opened -= 1
		if opened == 0 and i != len(pattern) - 1:
			return False
		if opened < 0:
			return False
	return opened == 0

def get_filled_pattern(pattern):
	op = 0
	cl = 0
	qs = 0
	for s in pattern:
		if s == '(':
			op += 1
		elif s == ')':
			cl += 1
		else:
			qs += 1
	need_op = 0
	need_cl = 0
	if op > cl:
		need_cl = op - cl
		qs -= need_cl
	else:
		need_op = cl - op
		qs -= need_op
	need_cl += qs // 2
	need_op += qs // 2
	res = list(pattern)
	for i in range(len(pattern)):
		if res[i] == '?':
			if need_op:
				res[i] = '('
				need_op -= 1
			else:
				res[i] = ')'
				need_cl -= 1
	return ''.join(res)
n = int(input())
pattern = list(input())
res_pattern = get_filled_pattern(pattern)
if is_correct(res_pattern):
	print(res_pattern)
else:
	print(':(')


n = int(input())
s = input()
a = []
for i in range(n):
	if s[i] == '?':
		a.append('(')
	else:
		a.append(s[i])
cnt = 0
ans = 0
for i in range(n):
	if a[i] == '(':
		cnt += 1
	else:
		cnt -= 1
	ans = min(ans, cnt)
for i in range(n - 1, -1, -1):
	if cnt > 0 and s[i] == '?':
		cnt -= 2
		a[i] = ')'
cnt = 0
b = []
for i in range(n):
	if a[i] == '(':
		cnt += 1
	else:
		cnt -= 1
	b.append(cnt)
if len(b) == 1 or min(b[:-1]) <= 0 or b[-1] != 0:
	ans = -1
if ans < 0:
	print(':(')
else:
	print(''.join(a))


N = int(input())
S = input()
if N % 2 != 0 or S[0] == ')' or S[N - 1] == '(':
	print(':(')
else:
	left = 0
	new_S = ['(']
	for c in S[1:N - 1]:
		new_S.append(c)
		if c == '(':
			left += 1
	new_S.append(')')
	left = N / 2 - left - 1
	new_S[0] = '('
	new_S[N - 1] = ')'
	impossible = False
	stack = []
	for (i, c) in enumerate(S):
		if i == 0 or i == N - 1:
			continue
		if c == '(':
			stack.append(c)
		elif c == ')':
			if len(stack) == 0:
				impossible = True
				break
			top = stack.pop()
			if top != '(':
				new_S[top] = '('
		elif left > 0:
			stack.append(i)
			left -= 1
		else:
			if len(stack) == 0:
				impossible = True
				break
			new_S[i] = ')'
			top = stack.pop()
			if top != '(':
				new_S[top] = '('
	if len(stack) != 0:
		impossible = True
	if impossible:
		print(':(')
	else:
		print(''.join(new_S))


import sys
input = sys.stdin.readline
from collections import *
n = int(input())
s = list(input()[:-1])
left = s.count('(')
right = s.count(')')
if n % 2 == 1 or s[0] == ')' or s[-1] == '(' or (left > n // 2) or (right > n // 2):
	print(':(')
	exit()
for i in range(n):
	if s[i] == '?':
		if left < n // 2:
			s[i] = '('
			left += 1
		else:
			s[i] = ')'
bal = 0
for i in range(n):
	if s[i] == '(':
		bal += 1
	else:
		bal -= 1
	if i < n - 1 and bal == 0 or bal < 0:
		print(':(')
		exit()
print(''.join(s))


n = int(input())
s = input()
cnt = 0
bal = 0
if n % 2 == 1 or s[0] == ')':
	print(':(')
	exit(0)
for i in range(n):
	if s[i] == '?':
		cnt += 1
	elif s[i] == '(':
		bal += 1
	else:
		bal -= 1
ans = ''
o = 0
c = 0
if cnt % 2 != bal % 2 or cnt < abs(bal):
	print(':(')
	exit(0)
else:
	if bal < 0:
		o += abs(bal)
	else:
		c += bal
	cnt -= abs(bal)
	o += cnt // 2
	c += cnt // 2
bal = 0
for i in range(n):
	if s[i] == '?':
		if o > 0:
			ans += '('
			o -= 1
			bal += 1
		else:
			ans += ')'
			c -= 1
			bal -= 1
	else:
		ans += s[i]
		if s[i] == '(':
			bal += 1
		else:
			bal -= 1
	if bal == 0 and i != n - 1:
		print(':(')
		exit(0)
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys
n = int(input())
s = list(input())
c = 0
d = 0
for i in range(n):
	if s[i] == '(':
		c += 1
	elif s[i] == ')':
		c -= 1
	else:
		d += 1
b = (d + c) // 2
a = d - b
t = 0
for i in range(n):
	if s[i] == '?':
		t += 1
		if t <= a:
			s[i] = '('
		else:
			s[i] = ')'
f = 0
e = 0
for i in range(n - 1):
	if s[i] == ')':
		e -= 1
	else:
		e += 1
	if e <= 0:
		f = 1
		break
if s[n - 1] == ')':
	e -= 1
else:
	e += 1
if e != 0 or f == 1:
	print(':(')
else:
	print(*s, sep='')


from collections import Counter
n = int(input())
data = list(input())

def checkData(data):
	counts = Counter(data)
	toClose = 0
	btoClose = len(data) / 2 - counts[')']
	for i in range(len(data) - 1, -1, -1):
		if data[i] is '?':
			if btoClose:
				data[i] = ')'
				btoClose -= 1
			else:
				data[i] = '('
	for (index, value) in enumerate(data):
		if value is '(':
			toClose += 1
		elif value is ')':
			toClose -= 1
			if toClose < 1:
				if index != len(data) - 1:
					return ':('
	if toClose:
		return ':('
	else:
		return ''.join(data)
print(checkData(data))


def solve(s, n):
	if n % 2 == 1:
		return None
	a = n // 2 - s.count('(')
	b = n // 2 - s.count(')')
	if a < 0 or b < 0:
		return None
	x = []
	for e in s:
		if e == '?':
			if a > 0:
				x.append('(')
				a -= 1
			else:
				x.append(')')
				b -= 1
		else:
			x.append(e)
	balance = 0
	for (i, e) in enumerate(x):
		balance += 1 if e == '(' else -1
		if balance <= 0 and i < n - 1:
			return None
	return ''.join(x)
n = int(input())
s = input()
res = solve(s, n)
if res:
	print(res)
else:
	print(':(')


n = int(input())
s = list(input())
if n % 2 == 0:
	if s.count('(') > n // 2 or s.count(')') > n // 2:
		print(':(')
	else:
		open = n // 2 - s.count('(')
		close = n // 2 - s.count(')')
		i = 0
		while i < n and open > 0:
			if s[i] == '?':
				s[i] = '('
				open -= 1
			i += 1
		while i < n and close > 0:
			if s[i] == '?':
				s[i] = ')'
				close -= 1
			i += 1
		sum = 0
		i = 0
		flag = 1
		while i < n:
			if s[i] == '(':
				sum += 1
			else:
				sum -= 1
			if sum < 0 or (sum == 0 and i != n - 1):
				flag = 0
				break
			i += 1
		if flag == 0:
			print(':(')
		else:
			print(''.join(s))
else:
	print(':(')


s = int(input())
inp = input()
open_count = inp.count('(')
close_count = inp.count(')')
open_new = s // 2 - open_count
close_new = s - open_count - close_count - open_new
bracket = list(inp)
for i in range(s):
	if bracket[i] == '?':
		if open_new > 0:
			bracket[i] = '('
			open_new -= 1
		else:
			bracket[i] = ')'
stck = [bracket[0]]
i = 1
while len(stck) > 0 and i < s:
	if bracket[i] == '(':
		stck.append(bracket[i])
	else:
		stck.pop()
	i += 1
if len(stck) == 0 and i == s:
	print(''.join(bracket))
else:
	print(':(')


from collections import Counter
from collections import defaultdict as dfd
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
from heapq import heapify, heappush, heappop
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

def st():
	return input().strip()

def stf():
	return file.readline().strip()

def read():
	return list(map(int, input().strip().split()))

def readf():
	return list(map(int, file.readline().strip().split()))

def rec(arr, pref, l, r, stt):
	stt.add(pref[r] - pref[l - 1])
	if l >= r or arr[l] == arr[r]:
		return
	mid = (arr[l] + arr[r]) // 2
	ind = bisect(arr, mid)
	rec(arr, pref, l, ind - 1, stt)
	rec(arr, pref, ind, r, stt)

def solve():
	n = nin()
	s = list(st())
	a = b = n // 2
	for i in s:
		a -= i == '('
		b -= i == ')'
	bal = 0
	fl = n % 2 ^ 1
	for i in range(n):
		if s[i] == '?':
			if a:
				s[i] = '('
				a -= 1
			else:
				s[i] = ')'
				b -= 1
		if s[i] == '(':
			bal += 1
		else:
			bal -= 1
		if i != n - 1 and bal <= 0:
			fl = 0
			break
	if bal == 0 and fl:
		ans_.append(''.join(s))
	else:
		ans_.append(':(')
solve()
for i in ans_:
	print(i)


n = int(input().strip())
ss = input().strip()
q = 0
for k in range(n):
	if ss[k] == '(':
		q += 1
ii = n // 2 - q
count = 0
s = ''
if n % 2 != 0:
	print(':(')
elif ii < 0:
	print(':(')
else:
	for k in range(n):
		if ss[k] == '?' and count < ii:
			s = s + '('
			count += 1
		elif ss[k] == '?' and count >= ii:
			s = s + ')'
		elif ss[k] == '(':
			s = s + '('
		else:
			s = s + ')'
	c2 = 0
	c3 = 0
	for k in range(n - 1):
		if s[k] == '(':
			c2 += 1
		else:
			c3 += 1
		if c3 >= c2:
			print(':(')
			break
	else:
		if s[n - 1] == '(':
			c2 += 1
		else:
			c3 += 1
		if c2 != c3:
			print(':(')
		else:
			print(s)


def main():
	n = int(input())
	s = input()
	n_open = s.count('(')
	n_close = s.count(')')
	n_blank = s.count('?')
	need_n_open = len(s) / 2 - n_open
	if need_n_open < 0:
		print(':(')
		return
	res = ''
	cnt = 0
	for i in range(len(s)):
		c = s[i]
		if c == '(':
			cnt += 1
			res += c
		elif c == ')':
			cnt -= 1
			res += c
		elif c == '?':
			if need_n_open > 0:
				res += '('
				cnt += 1
				need_n_open -= 1
			else:
				res += ')'
				cnt -= 1
		if cnt < 0:
			break
		if cnt == 0 and i < n - 1:
			res = ':('
			break
	if cnt != 0:
		res = ':('
	print(res)
main()


from collections import deque
import pdb
n = int(input())
s = list(input())

def possible(n, s):
	if n % 2:
		return None
	if s[0] == ')' or s[n - 1] == '(' or (len(s) > 2 and (s[1] == ')' or s[n - 2] == '(')):
		return None
	s[0] = '('
	s[n - 1] = ')'
	if len(s) > 2:
		s[1] = '('
		s[n - 2] = ')'
	stack = deque()
	for i in range(1, n - 1):
		if s[i] == ')' and len(stack) and (stack[-1][0] == '('):
			stack.pop()
		else:
			stack.append((s[i], i))
	stack_paren = deque()
	stack_star = deque()
	for i in range(len(stack)):
		(el, pos) = stack.popleft()
		if el == ')':
			if len(stack_paren):
				stack_paren.pop()
			elif len(stack_star):
				star_pos = stack_star.pop()
				s[star_pos] = '('
			else:
				return None
		elif el == '(':
			stack_paren.append(pos)
		else:
			stack_star.append(pos)
	paren_len = len(stack_paren)
	for i in range(paren_len):
		pos = stack_paren.pop()
		if len(stack_star) and stack_star[-1] > pos:
			pos1 = stack_star.pop()
			s[pos1] = ')'
		else:
			return None
	if len(stack_star) % 2:
		return None
	flag = True
	for pos in stack_star:
		s[pos] = '(' if flag else ')'
		flag = not flag
	return s
s = possible(n, s)
if s:
	print(''.join(s))
else:
	print(':(')


def is_true(s):
	v = 0
	for i in range(len(s)):
		if s[i] == '(':
			v = v + 1
		else:
			v = v - 1
		if v < 0:
			return False
	if v == 0:
		return True
	return False

def solve(s):
	n = len(s)
	if n % 2 == 0:
		if s[-1] != '(' and s[0] != ')':
			s = list(s)
			s[0] = '('
			s[-1] = ')'
			s = s[1:-1]
			v = 0
			nb = 0
			for i in range(len(s)):
				if s[i] == '?':
					nb = nb + 1
				if s[i] == '(':
					v = v + 1
				if s[i] == ')':
					v = v - 1
			if v > 0:
				for i in range(len(s) - 1, -1, -1):
					if s[i] == '?':
						s[i] = ')'
						nb = nb - 1
						v = v - 1
						if v == 0:
							break
			if v < 0:
				for i in range(len(s)):
					if s[i] == '?':
						s[i] = '('
						nb = nb - 1
						v = v + 1
						if v == 0:
							break
			if v == 0:
				for i in range(len(s)):
					if s[i] == '?':
						if nb > 0:
							s[i] = '('
							nb = nb - 2
						else:
							s[i] = ')'
				if is_true(s):
					return '(' + ''.join(s) + ')'
	return ':('
n = int(input())
s = input()
print(solve(s))


n = int(input())
s = input()
s = list(s)
a = n // 2 - s.count('(')
b = n - a - s.count(')')
for i in range(n):
	if s[i] == '?':
		s[i] = '('
		a -= 1
	if a <= 0:
		break
for i in range(n):
	if s[i] == '?':
		s[i] = ')'
		b -= 1
	if b <= 0:
		break
c = 0
for i in range(n):
	if s[i] == '(':
		c += 1
	else:
		c -= 1
	if c <= 0 and i < n - 1:
		c = 1
		break
if c != 0:
	print(':(')
else:
	for i in s:
		print(i, end='')


n = q = int(input())
k = list(input())
cntl = k.count('(')
cntr = k.count(')')
cntq = k.count('?')
for i in range(n):
	if k[i] == '?':
		if cntl < q // 2 and cntr + cntq >= q // 2:
			k[i] = '('
			cntl += 1
			cntq -= 1
		else:
			k[i] = ')'
			cntr += 1
			cntq -= 1

def check():
	cnt = 0
	m = 0
	for i in k:
		m += 1
		if i == '(':
			cnt += 1
		else:
			cnt -= 1
		if cnt == 0 and m < n or cnt < 0:
			return False
	return cnt == 0
print(''.join(k) if check() else ':(')


def ex():
	print(':(')
	exit()

def check(q):
	(o, c) = (0, 0)
	for i in q:
		if i == '(':
			o += 1
		else:
			if o == 0:
				return 0
			o -= 1
	return 1
n = int(input())
s = list(input())
if n % 2:
	ex()
o = s.count('(')
b = 0
for i in range(n):
	if i == 0:
		if s[i] == '?':
			b = 1
			s[i] = '('
			o += 1
		elif s[i] == '(':
			b = 1
		else:
			b = -1
		continue
	if b == 0:
		ex()
	if s[i] == '?':
		if o < n // 2:
			s[i] = '('
			b += 1
			o += 1
		else:
			s[i] = ')'
			b -= 1
	elif s[i] == '(':
		b += 1
	else:
		b -= 1
if b != 0 or not check(s):
	ex()
print(''.join(s))


import io, os
input = io.StringIO(os.read(0, os.fstat(0).st_size).decode()).readline
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
n = ii()
s = input().strip()
mx = [0] * (n + 1)
mn = [0] * (n + 1)
for i in range(1, n + 1):
	c = s[i - 1]
	if c == '(':
		mx[i] = mx[i - 1] + 1
		mn[i] = mn[i - 1] + 1
	elif c == ')':
		mx[i] = mx[i - 1] - 1
		mn[i] = mn[i - 1] - 1
	else:
		mx[i] = mx[i - 1] + 1
		mn[i] = mn[i - 1] - 1
if mn[n] <= 0 <= mx[n] and mx[n] % 2 == 0:
	cur = 0
	ok = 1
	res = [None] * (n + 1)
	for i in range(n, 0, -1):
		c = s[i - 1]
		if c == '(':
			cur -= 1
			res[i] = c
		elif c == ')':
			cur += 1
			res[i] = c
		elif mn[i - 1] <= cur + 1 <= mx[i - 1]:
			cur += 1
			res[i] = ')'
		else:
			cur -= 1
			res[i] = '('
		if i == 1 and cur > 0:
			ok = 0
			break
		if i > 1 and cur <= 0:
			ok = 0
			break
	if ok:
		print(''.join(res[1:]))
	else:
		print(':(')
else:
	print(':(')


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def __next__(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(next(self))

	def cal(self, s):
		if len(s) == 1:
			return s[0]
		if s[0] == 0:
			return self.cal(s[1:])
		v = 1
		for c in s:
			v *= c
		return v

	def solve(self):
		n = self.next_int()
		s = [x for x in next(self)]
		w = s.count('?')
		z = s.count('(')
		y = n - w - z
		ss = [x for x in s]
		if ss[0] == '?':
			ss[0] = '('
			z += 1
		if ss[-1] == '?':
			ss[-1] = ')'
			y += 1
		flag = n % 2 == 0 and ss[0] != ')' and (ss[-1] != '(') and (z * 2 <= n) and (y * 2 <= n)
		c = 1
		for i in range(1, n - 1):
			if not flag:
				break
			if ss[i] == '(':
				c += 1
			elif ss[i] == ')':
				c -= 1
			elif z * 2 < n:
				ss[i] = '('
				c += 1
				z += 1
			else:
				ss[i] = ')'
				c -= 1
				y -= 1
			if c == 0:
				flag = False
		if not flag:
			print(':(')
		else:
			print(''.join(ss))

def __starting_point():
	Main().solve()
__starting_point()


n = int(input())
inp = input()
(l, r) = (0, 0)
for i in range(n):
	if inp[i] == '(':
		l += 1
	elif inp[i] == ')':
		r += 1
lsaved = -1 * l + n // 2
rsaved = -1 * r + n // 2
res = []
for i in range(n):
	if inp[i] == '?':
		if lsaved:
			res.append('(')
			lsaved -= 1
		elif rsaved:
			res.append(')')
			rsaved -= 1
		else:
			print(':(')
			exit()
	else:
		res.append(inp[i])
ans = 0
rollingsum = 0
for i in range(n):
	if i >= 1 and rollingsum == 0:
		ans = 1
	if res[i] == '(':
		rollingsum += 1
	else:
		rollingsum -= 1
	if rollingsum < 0:
		ans = 1
if ans == 1 or rollingsum != 0:
	print(':(')
	exit()
print(''.join(res))


def verif(list, length, p):
	suma = 0
	for k in range(p, length):
		if list[k] == '(':
			suma += 1
		else:
			suma -= 1
		if suma < 0:
			return False
	if suma == 0:
		return True
	return False
l = int(input())
s = input()
if l % 2 != 0:
	print(':(')
else:
	a = 0
	b = 0
	for i in s:
		if i == '(':
			a += 1
		if i == ')':
			b += 1
	a = l // 2 - a
	b = l // 2 - b
	if a < 0 or b < 0:
		print(':(')
	else:
		s = list(s)
		for k in range(l):
			if s[k] == '?':
				if a > 0:
					s[k] = '('
					a -= 1
				else:
					s[k] = ')'
					b -= 1
		if verif(s, l, 0) == True and verif(s, l - 1, 1) == True:
			print(''.join(s))
		else:
			print(':(')


n = int(input())
s = list(input())
if n % 2 == 1:
	print(':(')
	exit()
(l, r) = (n // 2, n // 2)
q = 0
for i in range(n):
	if s[i] == '(':
		l -= 1
	elif s[i] == '?':
		q += 1
	else:
		r += 1
if l < 0 or r < 0:
	print(':(')
	exit()
tmp = 0
for i in range(n):
	if s[i] == '(':
		tmp += 1
	elif s[i] == '?':
		if l > 0:
			s[i] = '('
			l -= 1
			tmp += 1
		else:
			s[i] = ')'
			tmp -= 1
			r -= 1
	else:
		tmp -= 1
	if i != n - 1 and tmp == 0 or tmp < 0 or l < 0 or (r < 0):
		print(':(')
		exit()
print(''.join(s))


def valid(s):
	arr = []
	for i in s:
		if i == '(':
			arr.append('(')
		elif len(arr) > 0 and arr[len(arr) - 1] == '(':
			arr.pop()
		else:
			return 0
	return not len(arr)

def solve():
	N = int(input())
	s = input()
	result = [''] * N
	op = 0
	cl = 0
	if s[0] in ('(', '?'):
		result[0] = '('
		op += 1
	if s[-1] in (')', '?'):
		result[-1] = ')'
		cl += 1
	if op != 1 or cl != 1 or N % 2:
		print(':(')
		return
	if N == 2:
		print('()')
		return
	if s[1] in ('(', '?'):
		result[1] = '('
		op += 1
	if s[-2] in (')', '?'):
		result[-2] = ')'
		cl += 1
	if op != 2 or cl != 2:
		print(':(')
		return
	for i in range(2, N - 2):
		if s[i] == '(':
			op += 1
			result[i] = s[i]
		elif s[i] == ')':
			cl += 1
			result[i] = s[i]
	for i in range(2, N - 2):
		if s[i] == '?':
			if op < N // 2:
				op += 1
				c = '('
			else:
				cl += 1
				c = ')'
			result[i] = c
	s = ''.join(map(str, result))
	if op != cl or not valid(s[1:N - 1]):
		print(':(')
		return
	print(s)
solve()


n = int(input())
s = list(input())
(l, r) = (s.count('('), s.count(')'))
for i in range(n):
	if s[i] == '?' and 2 * l < n:
		s[i] = '('
		l += 1
	elif s[i] == '?' and 2 * l >= n:
		s[i] = ')'
kol = 0
for i in range(n):
	if s[i] == '(':
		kol += 1
	else:
		kol -= 1
	if kol <= 0 and i < n - 1 or (kol > 0 and i == n - 1):
		print(':(')
		exit(0)
print(''.join(s) if n % 2 == 0 else ':(')


import sys

def check(s):
	status = 0
	for char in s[:-1]:
		if char == '(':
			status += 1
		else:
			status -= 1
		if status <= 0:
			return ':('
	return s
n = int(input())
s = input()
if n % 2 != 0:
	print(':(')
else:
	leftcount = 0
	rightcount = 0
	for char in s:
		if char == '(':
			leftcount += 1
		if char == ')':
			rightcount += 1
	needed = n // 2
	if max(leftcount, rightcount) > needed:
		print(':(')
	else:
		leftneeded = n // 2 - leftcount
		leftadded = 0
		newchars = []
		for char in s:
			if char == '?':
				if leftadded < leftneeded:
					newchars.append('(')
					leftadded += 1
				else:
					newchars.append(')')
			else:
				newchars.append(char)
		print(check(''.join(newchars)))


n = int(input())
str = list(input())
sum_left = str.count('(')
sum_right = str.count(')')
for i in range(n):
	if str[i] == '?':
		if sum_left * 2 < n:
			sum_left += 1
			str[i] = '('
		else:
			sum_right += 1
			str[i] = ')'
cnt = 0
for i in range(n):
	cnt += 1 if str[i] == '(' else -1
	if cnt < 1 and i < n - 1:
		print(':(')
		exit()
	elif cnt != 0 and i == n - 1:
		print(':(')
		exit()
print(''.join(str))


n = int(input())
s = str(input()[:n])
a = [0] * n
ocount = 0
ccount = 0
notfulfilled = 0
pos = 1
if n % 2 != 0:
	print(':(')
else:
	for i in range(n):
		if s[i] == '(':
			a[i] = 1
			ocount += 1
		elif s[i] == ')':
			a[i] = -1
			ccount += 1
	for pos in range(n - 1):
		if a[pos] == 1:
			notfulfilled += 1
		elif a[pos] == 0:
			if ocount < n // 2:
				a[pos] = 1
				ocount += 1
				notfulfilled += 1
			elif notfulfilled > 1:
				a[pos] = -1
				ccount += 1
				notfulfilled -= 1
		elif a[pos] == -1:
			if notfulfilled > 1:
				notfulfilled -= 1
			else:
				print(':(')
				quit()
	if a[n - 1] == 1:
		print(':(')
		quit()
	else:
		a[n - 1] = -1
	if sum(a) == 0:
		for i in range(n):
			if a[i] == 1:
				print('(', end='')
			elif a[i] == -1:
				print(')', end='')
	else:
		print(':(')


n = int(input())
s = list(input())
i = 0
j = n - 1
flag = 0
if s[0] == ')' or n % 2 != 0 or s[-1] == '(':
	flag = 1
else:
	z = n // 2 - s.count('(')
	for i in range(n):
		if s[i] == '?':
			if z != 0:
				s[i] = '('
				z -= 1
			else:
				s[i] = ')'
	for i in range(n):
		if s[i] == '(':
			s[i] = 1
		else:
			s[i] = -1
	k = sum(s)
	if k != 0:
		flag = 1
	else:
		sum = 0
		for i in range(n - 1):
			sum += s[i]
			if sum == 0:
				flag = 1
				break
if flag == 1:
	print(':(')
else:
	for i in range(n):
		if s[i] == 1:
			s[i] = '('
		else:
			s[i] = ')'
	print(''.join(s))


n = int(input())
s = input()
s = list(s)
oc = 0
cc = 0
occ = s.count('(')
ccc = s.count(')')
flag = 0
if n % 2 != 0:
	flag = 1
for i in range(n):
	if s[i] == '(':
		oc += 1
	elif s[i] == ')':
		cc += 1
	elif occ < n // 2:
		s[i] = '('
		oc += 1
		occ += 1
	else:
		s[i] = ')'
		cc += 1
		ccc += 1
	if i != n - 1 and cc >= oc:
		flag = 1
if oc == cc and flag == 0:
	print(''.join(s))
else:
	print(':(')


import math

def main():
	n = int(input())
	s = input()
	left = s.count('(')
	right = s.count(')')
	s = list(s)
	if n % 2 != 0:
		print(':(')
	else:
		missing_left = n // 2 - left
		missing_right = n // 2 - right
		for i in range(n):
			if s[i] == '?':
				if missing_left > 0:
					s[i] = '('
					missing_left -= 1
				else:
					s[i] = ')'
					missing_right -= 1
		prefl = 0
		prefr = 0
		ok = True
		for i in range(n):
			if s[i] == '(':
				prefl += 1
			elif s[i] == ')':
				prefr += 1
			if i < n - 1:
				if prefr >= prefl:
					ok = False
					break
			elif prefr != prefl:
				ok = False
				break
		print(''.join(s) if ok else ':(')
main()


n = int(input())
if n % 2 == 1:
	print(':(')
	exit(0)
s = list(input())
d = 0
count1 = s.count('?')
count2 = s.count('(')
count3 = s.count(')')
i = n - 1
while count2 - count3 > 0:
	if i < 0:
		print(':(')
		exit(0)
	if s[i] == '?':
		s[i] = ')'
		count3 += 1
		count1 -= 1
	i -= 1
i = 0
while count2 - count3 < 0:
	if i == n:
		print(':(')
		exit(0)
	if s[i] == '?':
		s[i] = '('
		count2 += 1
		count1 -= 1
	i += 1
p = count1 // 2
q = n - 1
d = 0
for i in range(n):
	if s[i] == '(':
		d += 1
	elif s[i] == ')':
		d -= 1
		if d <= 0 and i < q:
			print(':(')
			exit(0)
	elif p != 0:
		s[i] = '('
		d += 1
		p -= 1
	else:
		s[i] = ')'
		d -= 1
		if d <= 0 and i < q:
			print(':(')
			exit(0)
if d > 0:
	print(':(')
	exit(0)
print(''.join(s))


n = int(input())
s = list(input())
answer = [0] * n
st = 0
en = 0
for i in range(n):
	if s[i] == '(':
		st += 1
	elif s[i] == ')':
		en += 1
for i in range(n):
	if s[i] == '?':
		if st < n // 2:
			s[i] = '('
			st += 1
		else:
			s[i] = ')'
found = True
temp = [0] * n
if s[0] == '(':
	temp[0] = 1
else:
	found = False
i = 1
while i < n and found:
	temp[i] = temp[i - 1]
	if s[i] == '(':
		temp[i] += 1
	else:
		temp[i] -= 1
	if temp[i] <= 0 and i < n - 1:
		found = False
		break
	i += 1
if found and temp[n - 1] == 0:
	print(''.join(s))
else:
	print(':(')


n = int(input())
s = list(input())
answer = []
left = s.count('(')
right = s.count(')')
l = r = 0
if n % 2 == 0:
	for item in s:
		if item == '(':
			l += 1
			answer.append('(')
		elif item == ')':
			r += 1
			answer.append(')')
			if r > l:
				print(':(')
				exit()
		elif left < n // 2:
			answer.append('(')
			left += 1
			l += 1
		else:
			answer.append(')')
			right += 1
			r += 1
	l = r = 0
	i = 0
	for item in answer:
		i += 1
		if item == '(':
			l += 1
		else:
			r += 1
		if r > l or (l == r and i != n and (answer[i - 1] == ')')) or (l != r and i == n):
			print(':(')
			exit()
	else:
		print(*answer, sep='')
else:
	print(':(')


import string, copy

def solution(s):
	if len(s) == 0:
		return ''
	if len(s) % 2 == 1:
		return ':('
	if s[0] not in '(?':
		return ':('
	if s[-1] not in ')?':
		return ':('
	s = s[1:-1]
	n = len(s)
	n1 = s.count('(')
	n2 = s.count(')')
	if n1 > n // 2 or n2 > n // 2:
		return ':('
	n1 = n // 2 - n1
	n2 = n // 2 - n2
	ans = []
	for i in range(len(s)):
		if s[i] != '?':
			ans.append(s[i])
		elif n1 > 0:
			ans.append('(')
			n1 -= 1
		else:
			ans.append(')')
	n = 0
	for c in ans:
		if c == '(':
			n += 1
		else:
			n -= 1
		if n < 0:
			return ':('
	if n != 0:
		return ':('
	return '(%s)' % ''.join(ans)

def parser():
	n = int(input())
	s = input()
	return s

def output(s):
	print(s)

def main():
	args = parser()
	result = solution(args)
	output(result)
main()


n = int(input())
s = list(input())
if n % 2 == 1 or s.count('(') > n // 2 or s.count(')') > n // 2:
	print(':(')
	exit()
ok = True
(op, cl) = (0, 0)
for i in range(n):
	if s[i] == ')':
		cl += 1
	else:
		op += 1
	if cl > op:
		print(':(')
		exit()
(op, cl) = (0, 0)
for i in range(n - 1, -1, -1):
	if s[i] == '(':
		op += 1
	else:
		cl += 1
	if cl < op:
		print(':(')
		exit()
al = s.count(')')
(op, cl) = (0, 0)
for i in range(n - 1, 0, -1):
	if s[i] == '(':
		op += 1
	elif s[i] == ')':
		cl += 1
		al -= 1
	elif cl + al == n // 2:
		s[i] = '('
		op += 1
	else:
		s[i] = ')'
		cl += 1
	if op >= cl:
		print(':(')
		exit()
s[0] = '('
print(''.join(s))


import sys

def main():
	n = int(input())
	s = list(sys.stdin.readline())
	(f, ouv) = (0, 0)
	for i in range(n):
		if s[i] == '?' or s[i] == '(':
			ouv += 1
		else:
			f += 1
			ouv -= 1
		if i < n - 1 and ouv <= 0:
			print(':(')
			exit(0)
	(f, ouv) = (0, 0)
	for i in range(n):
		if s[n - 1 - i] == '?' or s[n - 1 - i] == ')':
			f += 1
		else:
			ouv += 1
			f -= 1
		if i < n - 1 and f <= 0:
			print(':(')
			exit(0)
	if n % 2 == 1:
		print(':(')
		exit(0)
	k = n // 2 - ouv
	for i in range(n):
		if s[i] == '?' and k != 0:
			s[i] = '('
			k -= 1
		elif s[i] == '?':
			s[i] = ')'
	print(*s, sep='')
main()


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def possible(s):
	c = 0
	ans = 0
	for i in s:
		if i == '(':
			c += 1
		else:
			c -= 1
		if c == 0:
			ans += 1
		if c < 0:
			return False
	if ans > 1:
		return False
	return True
n = Int()
s = list(input())
ok = True
if len(s) % 2:
	ok = False
kill = [s[0], s[-1]]
if kill[0] == '?':
	kill[0] = '('
if kill[1] == '?':
	kill[1] = ')'
if kill != ['(', ')']:
	ok = False
op = n // 2 - s.count('(')
cl = n // 2 - s.count(')')
if op < 0 or cl < 0:
	ok = False
for i in range(n):
	if s[i] in ('(', ')'):
		continue
	if op:
		s[i] = '('
		op -= 1
	else:
		s[i] = ')'
		cl -= 1
if not ok:
	print(':(')
elif possible(s):
	print(*s, sep='')
else:
	print(':(')


def main():
	n = int(input())
	arr = list(input())
	if n & 1:
		print(':(')
		return 0
	left = n // 2 - arr.count('(')
	for i in range(n):
		if arr[i] == '?':
			if left:
				arr[i] = '('
				left -= 1
			else:
				arr[i] = ')'
	if arr[0] == ')' or arr[-1] == '(':
		print(':(')
		return 0
	left = 1
	right = 0
	for i in range(1, n):
		if right == left:
			print(':(')
			return 0
		if arr[i] == '(':
			left += 1
		else:
			right += 1
	if left != right:
		print(':(')
		return 0
	print(''.join(arr))
	return 0
main()


n = int(input())
A = list(input())
if A[0] == ')' or A[n - 1] == '(':
	print(':(')
else:
	A[0] = '('
	A[n - 1] = ')'
	a = A.count('(')
	b = 0
	c = 0
	for i in range(n):
		if A[i] == '(':
			b += 1
		elif A[i] == ')':
			b -= 1
		elif c < n // 2 - a:
			A[i] = '('
			c += 1
			b += 1
		else:
			A[i] = ')'
			b -= 1
		if b == 0 and i != n - 1:
			b = 1
			break
	if b != 0:
		print(':(')
	else:
		print(''.join(A))


n = int(input())
o = 0
work = True
s = list(input())
a = [0] * n
op = [0] * n
o = 0
c = 0
k = n - 1
for i in s[::-1]:
	a[k] = c
	op[k] = o
	k -= 1
	if i != '(':
		c += 1
	else:
		o += 1
o = 0
for (j, i) in enumerate(s):
	if o == 0 and j != 0:
		work = False
		break
	if i == '(':
		o += 1
	elif i == ')':
		o -= 1
		if o <= 0 and j != n - 1:
			work = False
			break
	elif a[j] > o + op[j]:
		s[j] = '('
		o += 1
	else:
		s[j] = ')'
		o -= 1
if work and o == 0:
	print(''.join(s))
else:
	print(':(')


from sys import stdin, stdout
N = int(input())
s = input()
if N % 2 == 1:
	print(':(')
	quit()
level = 0
left = 0
for i in range(N):
	if s[i] == '(':
		left += 1
s = list(s)
for i in range(N):
	if s[i] == '(':
		level += 1
	elif s[i] == ')':
		level -= 1
	elif s[i] == '?':
		if left < N // 2:
			s[i] = '('
			left += 1
			level += 1
		else:
			s[i] = ')'
			level -= 1
	if level <= 0 and i != N - 1:
		print(':(')
		quit()
if level != 0:
	print(':(')
	quit()
else:
	print(*s, sep='')


def fix(S):
	N = len(S)
	s = 0
	minS = 0
	for n in range(N):
		if S[n] == '(':
			s += 1
		elif S[n] == ')':
			s -= 1
		minS = min(minS, s)
	if minS < 0:
		for n in range(N):
			if S[n] == '?':
				S[n] = '('
				minS += 1
				s += 1
				if not minS:
					break
	if s > 0:
		for n in range(N - 1, -1, -1):
			if S[n] == '?':
				S[n] = ')'
				s -= 1
				if not s:
					break
	nq = 0
	for n in range(N):
		if S[n] == '?':
			nq += 1
	if nq % 2:
		return False
	added = 0
	for n in range(N):
		if S[n] == '?':
			if added < nq // 2:
				S[n] = '('
			else:
				S[n] = ')'
			added += 1
	s = 0
	for n in range(N):
		if S[n] == '(':
			s += 1
		else:
			s -= 1
		if s < 0:
			return False
	if s:
		return False
	return S

def sv():
	N = int(input())
	S = list(input())
	if N % 2:
		return False
	if S[0] == ')' or S[N - 1] == '(':
		return False
	if N == 2:
		print('()')
		return True
	f = fix(S[1:-1])
	if not f:
		return False
	print('(%s)' % ''.join(f))
	return True
if not sv():
	print(':(')


n = int(input())
s = input()
r = s[::-1]
(cl, cr, tcr) = (0, 0, 0)
k = 0
p = ['(']
if n % 2 == 0:
	if s[0] == ')' or s[n - 1] == '(':
		print(':(')
	else:
		for i in range(1, n - 1):
			if s[i] == ')':
				cl += 1
			if i - cl < cl:
				k = 1
				break
		for i in range(1, n - 1):
			if r[i] == '(':
				cr += 1
			if i - cr < cr:
				k = 1
				break
		if k == 0:
			if s[0] == '(':
				c = s.count('(') - 1
			else:
				c = s.count('(')
			i = 1
			for i in range(1, n - 1):
				if tcr + c >= n // 2 - 1:
					break
				if s[i] == '?':
					p.append('(')
					tcr += 1
				else:
					p.append(s[i])
			for j in range(i, n):
				if s[j] == '?':
					p.append(')')
				else:
					p.append(s[j])
			print(''.join(p))
		else:
			print(':(')
else:
	print(':(')


import collections

def B(s):
	if len(s) == 1:
		return ':('
	if s[0] == ')' or s[-1] == '(':
		return ':('
	s[0] = '('
	s[-1] = ')'
	bal = 0
	q = collections.deque()
	for i in range(1, len(s) - 1):
		if s[i] == '(':
			bal += 1
		elif s[i] == ')':
			bal -= 1
			if bal < 0:
				if len(q) == 0:
					return ':('
				s[q.popleft()] = '('
				bal += 1
		else:
			q.append(i)
	if bal > len(q):
		return ':('
	if (len(q) - bal) % 2 == 1:
		return ':('
	for _ in range(bal):
		s[q.pop()] = ')'
	for i in range(len(q) // 2):
		s[q[i]] = '('
		s[q[-1 - i]] = ')'
	bal = 0
	for i in range(1, len(s) - 1):
		bal += 1 if s[i] == '(' else -1
		if bal < 0:
			return ':('
	if bal > 0:
		return ':('
	return ''.join(s)
n = int(input())
s = list(input())
print(B(s))


n = int(input())
S = list(input())

def solve():
	if n % 2:
		return ':('
	L = [0] * n
	maxcnt = n // 2 - S.count('(')
	cnt = 0
	for i in range(n):
		if S[i] == '(':
			L[i] = 1
		elif S[i] == ')':
			L[i] = -1
		elif cnt < maxcnt:
			L[i] = 1
			S[i] = '('
			cnt += 1
		else:
			L[i] = -1
			S[i] = ')'
	judge = 0
	for i in range(n - 1):
		judge += L[i]
		if judge <= 0:
			return ':('
	judge += L[-1]
	if judge != 0:
		return ':('
	return ''.join(S)
print(solve())


n = int(input())
s = input()
if n % 2 != 0:
	print(':(')
	exit()
a = list(s)
xopen = a.count('(')
for i in range(len(a)):
	if a[i] == '?':
		if xopen < n // 2:
			xopen += 1
			a[i] = '('
		else:
			a[i] = ')'
diff = 0
for i in range(len(a)):
	if a[i] == '(':
		diff += 1
	else:
		diff -= 1
	if diff <= 0 and i != len(a) - 1:
		print(':(')
		exit()
if diff != 0:
	print(':(')
	exit()
print(''.join(a))


import sys
length = int(input())
op = 0
ret = '('
word = input()
if length % 2 == 1 or word[0] == ')' or word[-1] == '(':
	print(':(')
	sys.exit()
word2 = word[1:-1]
mc = word2.count(')')
mo = word2.count('(')
goal = (length - 2) // 2
nc = goal - mc
no = goal - mo
if nc < 0 or no < 0:
	print(':(')
	sys.exit()
for l in word2:
	if l == '(':
		ret += '('
		op += 1
	elif l == ')':
		ret += ')'
		op -= 1
	elif no > 0:
		no -= 1
		ret += '('
		op += 1
	else:
		nc -= 1
		ret += ')'
		op -= 1
	if op == -1:
		print(':(')
		sys.exit()
if op == 0:
	ret += ')'
	print(ret)
else:
	print(':(')


import sys

def rint():
	return list(map(int, sys.stdin.readline().split()))
n = int(input())
s = input()
o = s.count('(')
c = s.count(')')
ans = []
cnt = 0
ok = 0
for i in range(n):
	ans.append(s[i])
oc = o - c
if oc > 0:
	for i in range(n - 1, -1, -1):
		if oc == 0:
			break
		if ans[i] == '?':
			ans[i] = ')'
			oc -= 1
	if oc != 0:
		print(':(')
		return
qc = n - o - c - (o - c)
if qc % 2:
	print(':(')
	return
q = 0
for i in range(n):
	if q == qc:
		break
	if ans[i] == '?':
		if q < qc // 2:
			ans[i] = '('
		else:
			ans[i] = ')'
		q += 1
cnt = 0
for i in range(n):
	if ans[i] == '(':
		cnt += 1
	elif ans[i] == ')':
		cnt -= 1
	if cnt <= 0 and i != n - 1:
		print(':(')
		return
if cnt != 0:
	print(':(')
	return
print(''.join(ans))


a = int(input())
b = input()
if a > 2 and a % 2 == 0 and (b[0] != ')') and (b[-1] != '('):
	c = 0
	d = 0
	e = True
	k = ''
	i = 1
	q = 0
	while i < a - 1 and e == True:
		if b[i] == '(':
			c += 1
		elif b[i] == ')':
			c -= 1
		else:
			d += 1
		if c == 0:
			if d != 0:
				d -= 1
				q += 1
				c += 1
		elif c < 0:
			if d > 0:
				d -= 1
				q += 1
				c += 1
				if d > 1:
					d -= 1
					q += 1
					c += 1
			else:
				e = False
		i += 1
	t = c
	u = b[1:a - 1].count('?')
	u = u - t - q
	if u >= 0 and e == True:
		k += '('
		w = 1
		for i in range(1, a - 1):
			if b[i] == '(':
				k += '('
			elif b[i] == ')':
				k += ')'
			elif q > 0:
				k += '('
				q -= 1
			elif u > 0:
				if w == 1:
					k += '('
				else:
					k += ')'
				w *= -1
				u -= 1
			else:
				k += ')'
		k += ')'
		c = 0
		i = 1
		while i < a - 1 and e == True:
			if k[i] == '(':
				c += 1
			else:
				c -= 1
			if c < 0:
				e = False
			i += 1
		if e == False:
			print(':(')
		else:
			print(k)
	else:
		print(':(')
elif a == 2:
	if b[0] != ')' and b[1] != '(':
		print('()')
	else:
		print(':(')
else:
	print(':(')


t = input()
s = input()
zeros = 0
ones = 0
for i in s:
	if i == '(':
		zeros += 1
	elif i == ')':
		ones += 1
s = list(s)
i = 0
nbr_1 = 0
nbr_0 = 0
while i < len(s):
	if nbr_1 >= nbr_0 and nbr_1 != 0:
		break
	if s[i] == '(':
		nbr_0 += 1
		zeros -= 1
	elif s[i] == ')':
		nbr_1 += 1
	elif s[i] == '?' and nbr_0 + zeros < len(s) / 2:
		s[i] = '('
		nbr_0 += 1
	else:
		s[i] = ')'
		nbr_1 += 1
	i += 1
if nbr_0 != nbr_1 or nbr_0 < len(s) / 2:
	print(':(')
else:
	print(''.join(s))


kk = lambda : map(int, input().split())
ll = lambda : list(kk())
(n, s) = (int(input()), list(input()))
if s[-1] == '(' or s[0] == ')' or n % 2 == 1:
	print(':(')
	exit()
qcount = ocount = ccount = 0
for i in range(n):
	if s[i] == '?':
		qcount += 1
	elif s[i] == '(':
		ocount += 1
	else:
		ccount += 1
res = []
if s[0] == '(':
	ocount -= 1
else:
	qcount -= 1
if s[-1] == ')':
	ccount -= 1
else:
	qcount -= 1
val = 0
for i in range(1, n - 1):
	if val < 0:
		print(':(')
		exit()
	if s[i] == ')':
		res.append(')')
		val -= 1
		ccount -= 1
	elif s[i] == '(':
		val += 1
		res.append('(')
		ocount -= 1
	else:
		if val + ocount >= ccount + qcount:
			res.append(')')
			val -= 1
		else:
			res.append('(')
			val += 1
		qcount -= 1
if val != 0:
	print(':(')
	exit()
print('(' + ''.join(res) + ')')


n = int(input())
s = input()
if n % 2:
	print(':(')
	exit()
ans = ''
o = 0
c = 0
for i in s:
	if i == '(':
		o += 1
	elif i == ')':
		c += 1
if o > n // 2 or c > n // 2:
	print(':(')
	exit()
o = n // 2 - o
for i in s:
	if i == '?':
		if o:
			o -= 1
			ans += '('
		else:
			ans += ')'
	else:
		ans += i
for i in range(n - 1):
	if ans[i] == '(':
		o += 1
	else:
		o -= 1
	if o <= 0:
		print(':(')
		exit()
print(ans)


n = int(input())
s = list(input())
if n % 2 == 1:
	print(':(')
else:
	opa = n // 2 - s.count('(')
	k = 0
	for i in range(n):
		if s[i] == '(':
			k += 1
		elif s[i] == ')':
			k -= 1
			if i < n - 1 and k <= 0:
				print(':(')
				break
		elif opa > 0:
			opa -= 1
			s[i] = '('
			k += 1
		else:
			s[i] = ')'
			k -= 1
			if i < n - 1 and k <= 0:
				print(':(')
				break
	else:
		if k != 0:
			print(':(')
		else:
			print(''.join(s))


kol = int(input())
s = input()
leftB = s.count('(')
rightB = s.count(')')
q = s.count('?')
sres = ''
for i in range(kol):
	if s[i] == '?':
		if leftB * 2 < kol:
			sres += '('
			leftB += 1
		else:
			sres += ')'
	else:
		sres += s[i]
count = 0
for i in range(kol):
	count += 1 if sres[i] == '(' else -1
	if count < 1 and i < kol - 1:
		print(':(')
		exit()
	elif count != 0 and i == kol - 1:
		print(':(')
		exit()
print(sres)


from sys import stdout
from sys import stdin

def get():
	return stdin.readline().strip()

def getf():
	return [int(i) for i in get().split()]

def put(a, end='\n'):
	stdout.write(str(a) + end)

def putf(a, sep=' ', end='\n'):
	stdout.write(sep.join([str(i) for i in a]) + end)

def bruh():
	n = int(get())
	s = [i for i in get()]
	q = [0] * n
	a = s.count('(')
	b = s.count(')')
	cnt = 0
	for i in range(n):
		if a * 2 < n:
			if s[i] == '?':
				s[i] = '('
				a += 1
	for i in range(n):
		if b * 2 < n:
			if s[i] == '?':
				s[i] = ')'
				b += 1
	for i in range(n):
		if s[i] == ')':
			cnt -= 1
		else:
			cnt += 1
		if cnt <= 0 and i != n - 1 or (i == n - 1 and cnt != 0):
			put(':(')
			return 0
	putf(s, '')
bruh()


n = int(input())
s = input()
ln = len(s)
pt = ln // 2
if ln % 2 != 0:
	print(':(')
elif s[0] == ')' or s[-1] == '(':
	print(':(')
else:
	L1 = [0] * len(s)
	L2 = [0] * len(s)
	t1 = 0
	t2 = 0
	for i in range(len(s) - 1, -1, -1):
		L1[i] = t1
		L2[i] = t2
		if s[i] == '(':
			t1 = t1 + 1
		if s[i] == ')':
			t2 = t2 + 1
	tmp1 = 0
	tmp2 = 0
	ans = ''
	flag = 0
	for i in range(0, len(s)):
		if tmp2 > tmp1:
			flag = 1
			break
		if s[i] == '(':
			tmp1 += 1
			ans = ans + s[i]
		elif s[i] == ')':
			tmp2 += 1
			ans = ans + s[i]
		elif tmp1 + L1[i] + 1 > pt:
			ans = ans + ')'
			tmp2 = tmp2 + 1
		elif tmp2 + L2[i] + 1 > pt:
			ans = ans + '('
			tmp1 = tmp1 + 1
		elif tmp1 == tmp2 + 1 and i != len(s) - 1:
			ans = ans + '('
			tmp1 = tmp1 + 1
		elif tmp1 <= tmp2:
			ans = ans + '('
			tmp1 = tmp1 + 1
		else:
			ans = ans + '('
			tmp1 = tmp1 + 1
		if tmp2 > tmp1:
			flag = 1
			break
		if tmp1 == tmp2 and i != len(s) - 1:
			flag = 1
			break
	if tmp1 != tmp2:
		flag = 1
	if flag == 1:
		print(':(')
	else:
		print(ans)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())

def solve(dd, n):
	x = 0
	for i in range(n):
		if dd[i] == '(':
			x += 1
		elif dd[i] == ')':
			x -= 1
		if x <= 0 and i != n - 1:
			return -1
	if x == 0:
		return dd
	else:
		return -1
n = int(input())
l = input()
if n & 1:
	print(':(')
else:
	a = l.count('(')
	b = l.count(')')
	if a > n // 2 or b > n // 2:
		print(':(')
	else:
		a = n // 2 - a
		b = n // 2 - b
		l = l.replace('?', '(', a)
		l = l.replace('?', ')')
		ans = solve(l, n)
		if ans == -1:
			print(':(')
		else:
			print(l)


n = int(input())
if n % 2:
	print(':(')
	return
s = [c for c in input()]
if s[0] == ')' or s[-1] == '(':
	print(':(')
	return
s[0] = '('
s[-1] = ')'
count_open = s.count('(')
count_close = s.count(')')
half = n // 2
if count_close > half or count_open > half:
	print(':(')
	return
available = half - count_open
current = 0
for (i, x) in enumerate(s):
	if x == '(':
		current += 1
	elif x == ')':
		current -= 1
	elif available:
		current += 1
		available -= 1
		s[i] = '('
	else:
		current -= 1
		s[i] = ')'
	if current == 0 and i != n - 1:
		print(':(')
		return
print(''.join(s))


n = int(input().strip())
string = input().strip()
if n % 2 != 0:
	print(':(')
else:
	ans = ''
	if string[0] == ')' or string[-1] == '(':
		print(':(')
	else:
		bad = False
		stack = []
		ans = ['(']
		num = [0, 0]
		for i in string:
			if i == '(':
				num[0] += 1
			elif i == ')':
				num[1] += 1
		(a, b) = (n // 2 - num[0], n // 2 - num[1])
		(left, right) = (0, 1)
		if string[0] == '?':
			a -= 1
		for i in range(1, n):
			if left == right:
				bad = True
				break
			if string[i] == '?':
				if a <= 0:
					ans.append(')')
					left += 1
					b -= 1
				else:
					ans.append('(')
					right += 1
					a -= 1
			else:
				ans.append(string[i])
				if string[i] == '(':
					right += 1
				else:
					left += 1
		if a != 0 or b != 0 or bad:
			print(':(')
		else:
			print(''.join(ans))


def solve(s):
	if len(s) == 1 or s[-1] == '(' or s[0] == ')' or (len(s) % 2 == 1):
		return ':('
	ans = list(s)
	ans[0] = '('
	ans[-1] = ')'
	left = []
	star = []
	for i in range(1, len(s) - 1):
		if s[i] == '(':
			left += [i]
		elif s[i] == ')':
			if left:
				left.pop()
			elif star:
				p = star.pop()
				ans[p] = '('
			else:
				return ':('
		else:
			star += [i]
	while left and star and (left[-1] < star[-1]):
		left.pop()
		p = star.pop()
		ans[p] = ')'
	if left:
		return ':('
	if len(star) % 2 == 1:
		return ':('
	for i in range(0, len(star) // 2):
		p = star[i]
		ans[p] = '('
	for i in range(len(star) // 2, len(star)):
		p = star[i]
		ans[p] = ')'
	return ''.join(ans)
input()
s = input()
print(solve(s))


open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0 and open_list[pos] == stack[len(stack) - 1]:
				stack.pop()
			else:
				return 0
	if len(stack) == 0:
		return 1
n = int(input())
s = input()
left = s.count('(')
right = s.count(')')
re_left = n // 2 - left
re_right = n // 2 - right
arr = list(s)
for i in range(len(arr)):
	if arr[i] == '?':
		if re_left > 0:
			arr[i] = '('
			re_left -= 1
		elif re_right > 0:
			arr[i] = ')'
			re_right -= 1
ct_le = 0
ct_ri = 0
flag = 0
for i in range(len(arr)):
	if arr[i] == '(':
		ct_le += 1
	else:
		ct_ri += 1
	if ct_le == ct_ri and i != len(arr) - 1:
		flag = 1
s1 = ''.join(arr)
if flag == 0 and ct_le == ct_ri and check(s1):
	print(''.join(arr))
else:
	print(':(')


n = int(input())
s = list(input())
if n % 2:
	print(':(')
	quit()
l = n // 2 - s.count('(')
for i in range(n):
	if s[i] == '?':
		if l > 0:
			s[i] = '('
			l -= 1
		else:
			s[i] = ')'
bal = 0
if s[0] != '(' or s[-1] != ')':
	print(':(')
	quit()
for i in range(n):
	if s[i] == '(':
		bal += 1
	if s[i] == ')':
		bal -= 1
	if bal == 0 and i != n - 1:
		print(':(')
		quit()
	if bal != 0 and i == n - 1:
		print(':(')
		quit()
print(''.join(s))


import math
l = int(input())
s = input()
ans = []
if l % 2 == 1:
	print(':(')
	exit()
left = right = l // 2
unused_left = left
unused_right = right
gap = 0
for (i, v) in enumerate(s):
	if v == '(':
		unused_left -= 1
	elif v == ')':
		unused_right -= 1
if unused_left < 0 or unused_right < 0:
	print(':(')
	exit()
for (i, v) in enumerate(s):
	if v == '(':
		ans.append(v)
		gap += 1
	elif v == ')':
		ans.append(v)
		gap -= 1
	elif unused_left > 0:
		ans.append('(')
		unused_left -= 1
		gap += 1
	else:
		ans.append(')')
		gap -= 1
	if i < l - 1 and gap <= 0:
		print(':(')
		exit()
for v in ans:
	print(v, end='')


n = int(input())
s = list(input())
(l, r) = (s.count('('), s.count(')'))
for i in range(n):
	if s[i] == '?':
		if l + l < n:
			s[i] = '('
			l += 1
		else:
			s[i] = ')'
cnt = 0
for i in range(n):
	cnt += 1 if s[i] == '(' else -1
	if cnt < 1 and i < n - 1:
		print(':(')
		return
	elif cnt != 0 and i == n - 1:
		print(':(')
		return
print(''.join(s))


import math

def solve(a, n, l, r):
	x = 0
	y = 0
	for i in range(n):
		if a[i] == '?':
			if l > 0 and x + 1 != y:
				a[i] = '('
				l -= 1
			else:
				a[i] = ')'
				r -= 1
		if a[i] == '(':
			x += 1
		elif a[i] == ')':
			y += 1
		if x == y and i < n - 1:
			return False
		if x < y:
			return False
	if x != y:
		return False
	return True
n = int(input())
s = input()
a = []
q = 0
l = 0
r = 0
for c in s:
	if c == '?':
		q += 1
	elif c == '(':
		l += 1
	elif c == ')':
		r += 1
	a.append(c)
diff = l - r
q -= abs(diff)
if diff < 0:
	l = -diff + math.ceil(q / 2)
	r = q // 2
else:
	l = math.ceil(q / 2)
	r = diff + q // 2
flag = solve(a, n, l, r)
if flag:
	for c in a:
		print(c, end='')
else:
	print(':(')


from math import ceil
import sys
input = sys.stdin.readline
from collections import defaultdict as dd
n = int(input())
s = input().split()[0]
lol = 0
res = [0] * n
if n % 2 or s[0] == ')' or s[-1] == '(':
	print(':(')
else:
	st = []
	stt = []
	res[0] = '('
	res[-1] = ')'
	for i in range(1, n - 1):
		if s[i] == '(':
			st.append(i)
			res[i] = '('
		elif s[i] == '?':
			stt.append(i)
		elif len(st) != 0:
			st.pop()
			res[i] = ')'
		elif stt:
			ind = stt.pop()
			res[ind] = '('
			res[i] = ')'
		else:
			lol = 1
			break
	x = len(stt)
	if len(st) > x:
		lol = 1
	elif (x - len(st)) % 2:
		lol = 1
	else:
		cou = 0
		dif = len(st)
		for i in range(dif):
			a = st.pop()
			b = stt.pop()
			if a > b:
				lol = 1
				break
			else:
				res[b] = ')'
		while stt:
			if cou % 2 == 0:
				res[stt.pop()] = ')'
			else:
				res[stt.pop()] = '('
			cou += 1
	if lol:
		print(':(')
	else:
		print(*res, sep='')


def test_solve(s):
	n = len(s)
	s = list(s)
	olds = s[:]
	missing = [i for i in range(n) if s[i] == '?']
	tot = sum((c == '(' for c in s)) - sum((c == ')' for c in s))
	if (len(missing) - tot) % 2 != 0 or len(missing) - tot < 0 or len(missing) + tot < 0:
		return ':('
	x = (len(missing) - tot) // 2
	y = (len(missing) + tot) // 2
	for i in range(x):
		s[missing[i]] = '('
	for i in range(x, x + y):
		s[missing[i]] = ')'
	psum = [None] * n
	psum[0] = 1 if s[0] == '(' else -1
	for i in range(1, n):
		psum[i] = psum[i - 1] + (1 if s[i] == '(' else -1)
	if any((pref <= 0 for pref in psum[:-1])) or psum[-1] != 0:
		return ':('
	return ''.join(s)
n = int(input())
s = input().strip()
print(test_solve(s))


n = int(input())
s = input()
if n % 2 == 1 or s[0] not in ['(', '?']:
	print(':(')
else:
	(l, r) = (s.count('('), s.count(')'))
	if l > n // 2 or r > n // 2:
		print(':(')
	else:
		(pl, pr) = (abs(n // 2 - l), abs(n // 2 - r))
		cnt = 1
		sc = '('
		p = 1 if s[0] == '?' else 0
		i = 1
		while i < n:
			if s[i] == '(':
				cnt += 1
				sc += '('
			elif s[i] == ')':
				cnt -= 1
				sc += ')'
			elif s[i] == '?' and p < pl:
				cnt += 1
				p += 1
				sc += '('
			elif s[i] == '?' and p >= pl:
				cnt -= 1
				sc += ')'
			if cnt == 0 and i < n - 1:
				print(':(')
				break
			i += 1
		else:
			print(sc)


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mm = 1000000007

def solve():
	t = 1
	for it in range(t):
		n = nu()
		s = list(input())
		if n % 2 == 1:
			print(':(')
		else:
			gg = 0
			for i in range(n):
				if s[i] == '(':
					gg += 1
			if gg > n // 2:
				print(':(')
				continue
			dd = n // 2 - gg
			for i in range(n):
				if s[i] == '?':
					if dd > 0:
						s[i] = '('
						dd -= 1
					else:
						s[i] = ')'
			xc = [0] * n
			ss = 0
			for i in range(n):
				if s[i] == '(':
					ss += 1
				else:
					ss -= 1
				xc[i] = ss
			fl = True
			for i in range(n - 1):
				if xc[i] <= 0:
					fl = False
			if xc[n - 1] != 0:
				fl = False
			if fl:
				for i in range(n):
					print(s[i], end='')
				print()
			else:
				print(':(')
solve()


import sys
input = sys.stdin.readline
n = int(input())
s = list(input().rstrip())
if n % 2:
	print(':(')
	exit()
cnt = 0
c = 0
for i in range(n):
	if s[i] == '?':
		c += 1
	elif s[i] == '(':
		cnt += 1
a = n // 2 - cnt
b = n // 2 - (n - cnt - c)
if a < 0 or b < 0:
	print(':(')
	exit()
for i in range(n):
	if s[i] == '?':
		if a:
			s[i] = '('
			a -= 1
		else:
			s[i] = ')'
cnt = 0
f = True
for i in range(n):
	if s[i] == '(':
		cnt += 1
	else:
		cnt -= 1
	if cnt < 0:
		f = False
	if cnt == 0 and f and (i < n - 1):
		print(':(')
		exit()
	elif cnt == 0 and f:
		print(''.join(s))
		exit()
print(':(')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = list(input())
q = s.count('?')
l = s.count('(')
r = s.count(')')
d = n // 2 - l
if n % 2:
	print(':(')
	exit()
if d < 0:
	print(':(')
	exit()
if r > n // 2:
	print(':(')
	exit()
for i in range(n):
	if s[i] == '?':
		if d > 0:
			s[i] = '('
			d -= 1
		else:
			s[i] = ')'
cnt = 0
for i in range(n):
	if s[i] == '(':
		cnt += 1
	else:
		cnt -= 1
	if i < n - 1 and cnt <= 0:
		print(':(')
		exit()
	if i == n - 1 and cnt != 0:
		print(':(')
		exit()
print(''.join(s))


s = int(input())
string = input()
if s % 2 == 1:
	print(':(')
	exit(0)
output = list(string)
o = string.count('(')
running = 0
solvable = True
for (i, x) in enumerate(string):
	if x == '(' or x == ')':
		if x == '(':
			o -= 1
			running += 1
		else:
			running -= 1
	if x == '?':
		if i == s - 1:
			running -= 1
			output[i] = ')'
		elif running == 0 or running == 1:
			running += 1
			output[i] = '('
		elif s - i - o > running + o:
			running += 1
			output[i] = '('
		else:
			running -= 1
			output[i] = ')'
	if running < 0:
		solvable = False
		break
	if running == 0 and i < s - 1:
		solvable = False
		break
if running != 0 or not solvable:
	print(':(')
	exit(0)
print(''.join(output))


from __future__ import print_function, division
from sys import stdin, exit

def no_ans():
	print(':(')
	exit(0)
n = int(stdin.readline())
s = [ch for ch in stdin.readline()[:n]]
if n % 2 == 1 or s[0] == ')' or s[-1] == '(':
	no_ans()
s[0] = '('
s[-1] = ')'
cur_open = 0
open_left = (n - 1) // 2 - s[1:n - 1].count('(')
for (i, char) in enumerate(s[1:n - 1], 1):
	if char == '(':
		cur_open += 1
	elif char == '?' and open_left > 0:
		cur_open += 1
		open_left -= 1
		s[i] = '('
	else:
		cur_open -= 1
		s[i] = ')'
		if cur_open < 0:
			no_ans()
if cur_open != 0:
	no_ans()
print(''.join(s))


from math import ceil

def check(sym, n, m, r):
	count_sym = 0
	count_oth = 0
	for i in range(n, m, r):
		if st[i] == sym:
			count_sym += 1
		else:
			count_oth += 1
		if count_sym >= count_oth and i != m - r:
			return 0
	return 1
for _ in range(1):
	n = int(input())
	st = list(input().strip())
	if n % 2 == 1:
		print(':(')
		continue
	if check(')', 0, n, 1) + check('(', n - 1, -1, -1) < 2:
		print(':(')
		continue
	count_f = n // 2 - st.count('(')
	count_b = n // 2 - st.count(')')
	count = 0
	i = 0
	while count < count_f:
		if st[i] == '?':
			st[i] = '('
			count += 1
		i += 1
	while count < count_b + count_f:
		if st[i] == '?':
			st[i] = ')'
			count += 1
		i += 1
	for i in st:
		print(i, end='')


n = int(input())
s = list(input())

def findbal(a, th=0):
	b = 0
	for c in a:
		if c == '(':
			b += 1
		elif c == ')':
			b -= 1
			if th > 0 and b < th:
				return b
	return b
can = s[0] != ')' and s[-1] != '(' and (n % 2 == 0)
if can:
	s[0] = '('
	s[-1] = ')'
	b = findbal(s)
	q = sum([1 if c == '?' else 0 for c in s])
	q -= b
	q = q // 2
	if q < 0:
		can = False
	for i in range(n):
		if s[i] == '?':
			s[i] = '(' if q > 0 else ')'
			q -= 1
	can = findbal(s[:-1], 1) == 1
if can:
	print(''.join(s))
else:
	print(':(')


l = int(input())
s = input()
o = s.count('(')
c = s.count(')')
d = s.count('?')
(numo, numc) = (0, 0)
if o < c:
	numo += c - o
else:
	numc += o - c
d -= numo
d -= numc
numo += d // 2
numc += d // 2
d -= 2 * d // 2
u = s.replace('?', '(', numo).replace('?', ')', numc)
p = 0
v = True
for c in u[:l - 1]:
	if c == '(':
		p += 1
	else:
		p -= 1
	if p <= 0:
		v = False
		break
if u[l - 1] == '(':
	p += 1
else:
	p -= 1
if p != 0:
	v = False
if v and d == 0:
	print(u)
else:
	print(':(')


import math

def main():
	n = int(input())
	s = list(input())
	(co, cc) = (0, 0)
	if len(s) % 2 == 1:
		print(':(')
	else:
		(x, y) = (s.count('('), s.count(')'))
		(rx, ry) = (n // 2 - x, n // 2 - y)
		for i in range(n):
			if co == 0 and i != 0:
				cc = 1
				break
			if s[i] == '(':
				co += 1
			elif s[i] == ')':
				co -= 1
			elif co == 0 and i == 0:
				s[i] = '('
				co += 1
				rx -= 1
			elif co == 1 and i == n - 1:
				s[i] = ')'
				co -= 1
				ry -= 1
			elif co == 1:
				s[i] = '('
				co += 1
				rx -= 1
			elif co > 1:
				if rx > 0:
					s[i] = '('
					co += 1
					rx -= 1
				else:
					s[i] = ')'
					co -= 1
					ry -= 1
			if co < 0 or rx < 0 or ry < 0:
				cc = 1
				break
		print(':(' if cc == 1 or co != 0 else ''.join(s))
main()


n = int(input())
s = input()
string = ''
scnt = 0
scntleft = s.count('(')
scntright = s.count(')')
em = 0
if n % 2 == 1:
	em = 1
elif scntleft > n / 2 or scntright > n / 2:
	em = 1
else:
	for i in range(n):
		if s[i] == '(':
			string += s[i]
			scnt += 1
		elif s[i] == ')':
			string += s[i]
			scnt -= 1
			if scnt <= 0 and i < n - 1:
				em = 1
				break
		elif s[i] == '?':
			if scntleft < n / 2:
				string += '('
				scnt += 1
				scntleft += 1
			else:
				string += ')'
				scnt -= 1
				scntright += 1
				if scnt <= 0 and i < n - 1:
					em = 1
					break
if em == 1 or scnt > 0:
	print(':(')
else:
	print(string)


n = int(input())
o = 0
c = 0
s = input()
if n % 2 == 1:
	print(':(')
	exit(0)
for i in range(n):
	if s[i] == '(':
		o += 1
	elif s[i] == ')':
		c += 1
o = n // 2 - o
c = n // 2 - c
count = 0
result = ''
for i in range(n):
	if s[i] == '?':
		if o > 0:
			result += '('
			o -= 1
			count += 1
		elif c > 0:
			result += ')'
			c -= 1
			count -= 1
	elif s[i] == '(':
		result += '('
		count += 1
	elif s[i] == ')':
		result += ')'
		count -= 1
	if count <= 0 and i != n - 1:
		print(':(')
		exit(0)
	if i == n - 1 and count != 0:
		print(':(')
		exit(0)
print(result)


def get_answer(n, s):
	if n % 2:
		return ':('
	L = s.count('(')
	if L > n // 2:
		return ':('
	s = s.replace('?', '(', n // 2 - L)
	s = s.replace('?', ')')
	L = R = 0
	for i in range(n - 1):
		if s[i] == '(':
			L += 1
		else:
			R += 1
		if L <= R:
			return ':('
	return s
print(get_answer(int(input()), input()))


n = int(input())
s = input()
f = 1
p = ''
pos = []
if s[0] == ')' or n % 2 == 1:
	f = 0
else:
	p += '('
k = 1
for i in range(1, n - 1):
	if k < 1:
		if len(pos) > 0:
			ind = pos.pop()
			p = p[:ind] + '(' + p[ind + 1:]
			k += 2
		else:
			f = 0
			break
	if s[i] == '?':
		if k == 1:
			p += '('
		else:
			pos.append(i)
			p += ')'
	else:
		p += s[i]
	if p[-1] == '(':
		k += 1
	if p[-1] == ')':
		k -= 1
if f and (s[n - 1] == '?' or s[n - 1] == ')'):
	p += ')'
else:
	p += '('
if f and k == 1 and (p[-1] == ')'):
	print(p)
else:
	print(':(')


n = int(input())
seq = list(input())
ob = cb = res = 0
for i in range(0, n):
	if seq[i] == '(':
		ob = ob + 1
	elif seq[i] == ')':
		cb = cb + 1
for i in range(0, n):
	if seq[i] == '?':
		if ob < n / 2:
			seq[i] = '('
			ob = ob + 1
		else:
			seq[i] = ')'
			cb = cb + 1
	if seq[i] == '(':
		res = res + 1
	elif seq[i] == ')':
		res = res - 1
	if res < 1 and i != n - 1:
		res = -1
		break
if res == 0:
	seq = ''.join(seq)
	print(seq)
else:
	print(':(')


_str = str
(n, str) = (int(input()), list(input()))
if str[0] == '?':
	str[0] = '('
if str[-1] == '?':
	str[-1] = ')'
(pp, nn) = (n // 2, n // 2)
for ch in str:
	if ch == '(':
		pp -= 1
	if ch == ')':
		nn -= 1
if n % 2 == 1 or str[0] != '(' or str[-1] != ')' or (pp < 0) or (nn < 0):
	print(':(')
	exit(0)
(res, sum) = ([], 0)
for ch in str:
	if ch == '(':
		res.append('(')
		sum += 1
	elif ch == ')':
		res.append(')')
		sum -= 1
	elif pp > 0:
		res.append('(')
		sum += 1
		pp -= 1
	elif nn > 0:
		res.append(')')
		sum -= 1
		nn -= 1
	else:
		print(':(')
		exit(0)
	if sum <= 0:
		break
if sum == 0 and len(res) == n:
	print(_str(res).replace(', ', '').replace('[', '').replace(']', '').replace("'", ''))
else:
	print(':(')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def ispos(s):
	cnt = 0
	for i in range(len(s)):
		if s[i] == '(':
			cnt += 1
		else:
			cnt -= 1
		if cnt == 0 and i != len(s) - 1 or cnt < 0:
			return False
	if cnt != 0:
		return False
	return True
n = int(ri())
s = ri()
s = [i for i in s]
(cnt1, cnt2) = (0, 0)
for i in s:
	if i == '(':
		cnt1 += 1
	elif i == ')':
		cnt2 += 1
for i in range(len(s)):
	if s[i] == '?':
		if (cnt1 + 1) * 2 <= n:
			s[i] = '('
			cnt1 += 1
		else:
			s[i] = ')'
if ispos(s):
	print(''.join(s))
else:
	print(':(')


import sys
input = sys.stdin.readline
n = int(input())
a = list(input())
if n % 2 != 0:
	print(':(')
else:
	b = a.count('(')
	c = a.count(')')
	if b > n // 2 or c > n // 2:
		print(':(')
	else:
		b = n // 2 - b
		c = n // 2 - c
		d = 0
		for i in range(n):
			if a[i] == '?':
				a[i] = '('
				d += 1
			if d == b:
				break
		d = 0
		for i in range(n):
			if a[i] == '?':
				a[i] = ')'
				d += 1
			if d == c:
				break
		d = 0
		e = 0
		f = []
		for i in range(n - 1):
			if a[i] == '(':
				d += 1
			else:
				d += -1
			f.append(d)
		if min(f) < 1:
			e = 1
		if e == 0:
			print(''.join(a))
		else:
			print(':(')


n = int(input())
if n % 2:
	print(':(')
	exit(0)
s = list(input())
ans = ''
(c1, c2) = (s.count('('), s.count(')'))
cnt90 = 0
(cnt9, cnt0) = (0, 0)
for i in s[:-1]:
	if i == '(':
		cnt90 += 1
		if cnt9 + cnt90 > n // 2:
			print(':(')
			exit(0)
		ans += i
	elif i == ')':
		cnt0 += 1
		if cnt0 > n // 2:
			print(':(')
			exit(0)
		ans += i
	elif cnt9 + c1 < n // 2:
		ans += '('
		cnt9 += 1
	else:
		ans += ')'
		cnt0 += 1
	if cnt90 + cnt9 <= cnt0:
		print(':(')
		exit(0)
if s[-1] == '(' or cnt9 + cnt90 != n // 2:
	print(':(')
	exit(0)
print(ans + ')')


n = int(input())
s = input()

def f():
	level = 0
	blank = 0
	filled = []
	for (i, c) in enumerate(s):
		if c == '(':
			level += 1
		elif c == ')':
			level -= 1
			if level < 0:
				if blank < 0:
					return
				filled.append('(')
				blank -= 1
				level += 1
		else:
			blank += 1
	filled_rev = []
	while level > 0:
		if blank < 0:
			return
		filled_rev.append(')')
		blank -= 1
		level -= 1
	if blank % 2 != 0:
		return
	while blank > 0:
		filled.append('(')
		filled_rev.append(')')
		blank -= 2
	f = filled + filled_rev[::-1]
	z = list(s)
	j = 0
	for (i, c) in enumerate(s):
		if c == '?':
			z[i] = f[j]
			j += 1
	l = 0
	for (i, c) in enumerate(z):
		if c == '(':
			l += 1
		else:
			l -= 1
		if l == 0 and i != n - 1:
			return
	if l != 0:
		return
	return ''.join(z)
z = f()
print(z if z else ':(')


n = int(input())
s = list(input())
if n % 2:
	print(':(')
	exit()
res = n // 2
for i in range(n):
	if s[i] == '(':
		res -= 1
for i in range(n):
	if s[i] != '?':
		continue
	if res > 0:
		s[i] = '('
		res -= 1
	else:
		s[i] = ')'
c = 0
for i in range(n):
	if s[i] == '(':
		c += 1
	else:
		c -= 1
	if c < 0 or (i < n - 1 and c == 0):
		print(':(')
		exit()
if c:
	print(':(')
else:
	print(''.join(s))


n = int(input())
s = input()
import sys
if n % 2 == 1:
	print(':(')
	sys.exit(0)
d = {}
d['('] = 1
d[')'] = -1
d['?'] = 0
suma = 0
cale = 0
dop = [[0, 0] for i in range(n)]
dop[n - 1] = [0, 0]
for i in range(1, n):
	j = n - i - 1
	if s[j + 1] == ')':
		dop[j] = [max(1, dop[j + 1][0] + 1), dop[j + 1][1] + 1]
	if s[j + 1] == '(':
		dop[j] = [max(1, dop[j + 1][0] - 1), dop[j + 1][1] - 1]
	if s[j + 1] == '?':
		dop[j] = [max(1, dop[j + 1][0] - 1), dop[j + 1][1] + 1]
	if dop[j][0] > dop[j][1]:
		print(':(')
		sys.exit(0)
suma = 0
odp = []
pyk = 0
for i in range(n):
	if s[i] != '?':
		odp.append(s[i])
		if s[i] == '(':
			suma += 1
		if s[i] == ')':
			pyk += 1
			suma -= 1
	elif suma + 1 >= dop[i][0] and suma + 1 <= dop[i][1]:
		odp.append('(')
		suma += 1
	elif suma - 1 >= dop[i][0] and suma - 1 <= dop[i][1]:
		odp.append(')')
		suma -= 1
	else:
		print(':(')
		sys.exit(0)
if pyk > n // 2:
	print(':(')
else:
	for i in range(n):
		print(odp[i], end='')


def brackets(n, s):
	s = list(s)
	if n % 2:
		return ':('
	(count1, count2) = (n // 2, 0)
	for i in range(n):
		if s[i] == '(':
			count1 -= 1
	for i in range(n):
		if s[i] != '?':
			continue
		if count1 > 0:
			s[i] = '('
			count1 -= 1
		else:
			s[i] = ')'
	for i in range(n):
		if s[i] == '(':
			count2 += 1
		else:
			count2 -= 1
		if count2 < 0 or (i < n - 1 and count2 == 0):
			return ':('
	if count2:
		return ':('
	return ''.join(s)
m = int(input())
t = input()
print(brackets(m, t))


import sys
import math
from collections import defaultdict, deque
import heapq
n = int(sys.stdin.readline())
s = sys.stdin.readline()[:-1]
if n == 1 or s[0] == ')' or s[1] == ')' or (n % 2 == 1):
	print(':(')
	sys.exit()
ans = [0 for _ in range(n)]
ans[0] = '('
ans[1] = '('
cnt = 0
cnto = 0
for i in range(n):
	if s[i] == '(':
		cnt += 1
rem = n // 2 - cnt
if s[0] == '?':
	rem -= 1
if s[1] == '?':
	rem -= 1
ans[0] = '('
ans[1] = '('
for i in range(2, n - 1):
	if s[i] == '?':
		if cnto < rem:
			ans[i] = '('
			cnto += 1
		else:
			ans[i] = ')'
	else:
		if s[i] == '(':
			pass
		ans[i] = s[i]
if s[-1] != '?':
	if s[-1] == '(':
		print(':(')
		sys.exit()
ans[-1] = ')'
res = 0
for i in range(n):
	if (res < 0 or res == 0) and i != n - 1 and (i != 0):
		print(':(')
		sys.exit()
	if ans[i] == '(':
		res += 1
	else:
		res -= 1
if res > 0:
	print(':(')
	sys.exit()
print(''.join((x for x in ans)))


n = int(input())
s = [i for i in input()]
o = 0
z = 0
O = s.count('(')
Z = s.count(')')
V = s.count('?')
on = (V - (O - Z)) // 2
flag = 0
if on >= 0:
	for i in range(n):
		if s[i] == '(':
			o += 1
		if s[i] == ')':
			z += 1
		if s[i] == '?':
			if on > 0:
				s[i] = '('
				o += 1
				on -= 1
			else:
				s[i] = ')'
				z += 1
		if z == o and i != len(s) - 1:
			flag = 1
			break
		if z > o:
			flag = 1
			break
else:
	flag = 1
if z != o:
	flag = 1
if flag == 0:
	print(*s, sep='')
else:
	print(':(')


import sys
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
n = int(input())
s = list(input())
if n % 2:
	print(':(')
elif s[0] == ')':
	print(':(')
else:
	(p, q) = (s.count('('), s.count(')'))
	if p > n // 2 or q > n // 2:
		print(':(')
	else:
		p = n // 2 - p
		q = n // 2 - q
		(c1, c2) = (0, 0)
		for i in range(n):
			if s[i] == '?':
				if c1 < p:
					s[i] = '('
					c1 += 1
				else:
					s[i] = ')'
		x = dc(int)
		x[s[0]] += 1
		f = 0
		for i in range(1, n - 1):
			if x[')'] >= x['(']:
				f = 1
				break
			else:
				x[s[i]] += 1
		x[s[-1]] += 1
		if f or s[-1] == '(' or x['('] != x[')']:
			print(':(')
		else:
			print(''.join(s))


n = int(input())
s = list(input())
if n % 2 == 1 or s[0] == ')' or s[len(s) - 1] == '(':
	print(':(')
else:
	q = s.count('?')
	dl = s.count('(')
	dr = s.count(')')
	t = (dl + dr + q) // 2
	if dl > dr:
		t = t - dl
		dl = t
		dr = q - t
	elif dr > dl:
		t = t - dr
		dr = t
		dl = q - t
	else:
		dr = q // 2
		dl = q // 2
	for i in range(len(s)):
		if s[i] == '?':
			if dl > 0:
				s[i] = '('
				dl -= 1
			elif dr > 0:
				s[i] = ')'
				dr -= 1
		if dr == dl and dl == 0:
			break
	st = [s[0]]
	fail = False
	for i in range(1, len(s)):
		if st == []:
			fail = True
			break
		elif s[i] == '(':
			st.append(i)
		elif s[i] == ')':
			st.pop()
	if fail or len(st) > 0:
		print(':(')
	else:
		print(''.join(s))


y = input()
x = list(input())
(c, d, e, f) = (0, 0, 0, 0)
z = True
for i in range(len(x)):
	if x[i] == '(':
		d += 1
	elif x[i] == ')':
		d -= 1
	else:
		c += 1
	if len(x) % 2 == 1:
		z = False
		print(':(')
		break
if z:
	for i in range(len(x)):
		if x[i] == '?' and d < c:
			x[i] = '('
			d += 1
			c -= 1
		elif x[i] == '?':
			x[i] = ')'
	for i in range(len(x)):
		if x[i] == '(':
			e += 1
		elif x[i] == ')':
			f += 1
		if e - f <= 0 and i != len(x) - 1 or (e != f and i == len(x) - 1):
			print(':(')
			z = False
			break
	if z:
		print(''.join(x))


import sys
from collections import Counter
N = int(input())
ls = list(input())
c = Counter(ls)
if N % 2 == 1 or ls[-1] == '(' or c[')'] > N // 2 or (c[')'] > N // 2):
	print(':(')
	sys.exit()
total_l = c['(']
left_l = 0
left_r = 0
total_r = c[')']
for i in range(N):
	if ls[i] == '?':
		if total_l < N // 2:
			total_l += 1
			left_l += 1
			ls[i] = '('
		else:
			ls[i] = ')'
			left_r += 1
	elif ls[i] == '(':
		left_l += 1
	else:
		left_r += 1
	if i < N - 1 and left_r >= left_l:
		print(':(')
		sys.exit()
c = Counter(ls)
if c['('] != c[')']:
	print(':(')
	sys.exit()
else:
	print(''.join(ls))


import sys
sys_input = sys.stdin.readline

def si():
	return sys_input().rstrip()

def ii():
	return int(si())

def sti():
	return si().split()

def iti():
	return map(int, sti())

def sli():
	return list(si())

def ili():
	return list(iti())
n = ii()
s = sli()

def main():
	if n == 2 and s[0] != ')' and (s[1] != '('):
		return '()'
	if n % 2 == 1 or ')' in s[:2] or '(' in s[-2:]:
		return ':('
	s[0] = '('
	s[1] = '('
	s[-2] = ')'
	s[-1] = ')'
	p_num = n // 2
	open_num = s.count('(')
	close_num = s.count(')')
	if open_num > p_num or close_num > p_num:
		return ':('
	result = s
	cum_p_num = 0
	q = n - open_num - close_num
	for (i, c) in enumerate(s):
		if c == '(':
			cum_p_num += 1
			open_num -= 1
		if c == ')':
			cum_p_num -= 1
			close_num -= 1
		if c == '?':
			if cum_p_num + open_num + q > close_num and cum_p_num + open_num == close_num + q:
				result[i] = ')'
				cum_p_num -= 1
			else:
				result[i] = '('
				cum_p_num += 1
			q -= 1
		if i < n - 1 and cum_p_num <= 0:
			return ':('
	return ''.join(result)
print(main())


n = int(input(''))
s = list(input(''))
x = 0
y = 0
p = 0
q = 0
z = 0
m = 0
for i in range(n):
	if s[i] == '(':
		m += 1
if n % 2 == 1:
	print(':(')
else:
	for i in range(n - 1):
		if s[-i - 1] == '(':
			x += 1
		else:
			y += 1
		if s[i] == ')':
			p += 1
		else:
			q += 1
		if x >= y:
			z = 1
			break
		if p >= q:
			z = 1
			break
	if z == 1:
		print(':(')
	else:
		for i in range(n):
			if s[i] == '?':
				if m >= n // 2:
					s[i] = ')'
				else:
					s[i] = '('
					m += 1
			print(s[i], end='')


n = int(input())
s = input()

def solve(s):
	if n % 2 == 1:
		return ':('
	s = list(s)
	cnt = n // 2 - sum((1 if i == '(' else 0 for i in s))
	if cnt < 0:
		return ':('
	l = 0
	for (i, c) in enumerate(s):
		if c == '(':
			l += 1
		elif c == '?':
			if cnt > 0:
				s[i] = '('
				l += 1
				cnt -= 1
			else:
				s[i] = ')'
				l -= 1
				if l <= 0 and i != n - 1:
					return ':('
		elif c == ')':
			l -= 1
			if l <= 0 and i != n - 1:
				return ':('
	if l == 0:
		return ''.join(s)
	else:
		return ':('
res = solve(s)
print(res)


def calc():
	N = int(input())
	s = input()
	A = [[0, 0] for _ in range(N)]
	B = [0] * (N + 1)
	if N % 2 or s[0] == ')' or s[-1] == '(':
		return ':('
	for i in range(N - 1):
		if s[i] == '(':
			A[i + 1][0] = A[i][0] + 1
			A[i + 1][1] = A[i][1] + 1
		elif s[i] == ')':
			A[i + 1][0] = A[i][0] + (-1 if A[i][0] > 1 else 1)
			A[i + 1][1] = A[i][1] - 1
		else:
			A[i + 1][0] = A[i][0] + (-1 if A[i][0] > 1 else 1)
			A[i + 1][1] = A[i][1] + 1
		if A[i + 1][0] == 0 or A[i + 1][1] < A[i + 1][0]:
			return ':('
	if A[N - 1][0] > 1:
		return ':('
	B[N] = 0
	for i in range(N)[::-1]:
		if s[i] == ')':
			B[i] = B[i + 1] + 1
		elif s[i] == '(':
			B[i] = B[i + 1] - 1
		elif B[i + 1] - 1 >= A[i][0]:
			B[i] = B[i + 1] - 1
		elif B[i + 1] + 1 <= A[i][1]:
			B[i] = B[i + 1] + 1
		else:
			return ':('
	C = ['(' if B[i] + 1 == B[i + 1] else ')' for i in range(N)]
	return ''.join(C)
print(calc())


n = int(input())
s = input()
if n % 2 != 0:
	print(':(')
else:
	total_left = n / 2 - s.count('(')
	k = []
	(c, i) = (0, 0)
	while i < n:
		if s[i] == '(':
			k.append('(')
			c += 1
		elif s[i] == ')':
			k.append(')')
			c -= 1
		elif total_left > 0:
			total_left -= 1
			k.append('(')
			c += 1
		else:
			k.append(')')
			c -= 1
		if c < 0:
			print(':(')
			break
		if c == 0 and i != n - 1:
			print(':(')
			break
		elif i == n - 1 and c != 0:
			print(':(')
			break
		elif i == n - 1 and c == 0:
			print(''.join(k))
		i += 1


n = int(input())
seq = list(input())
l = 0
r = 0
for c in seq:
	if c == '(':
		l += 1
	elif c == ')':
		r += 1
for i in range(len(seq) - 1, -1, -1):
	if seq[i] == '?':
		if r < n / 2:
			seq[i] = ')'
			r += 1
		else:
			seq[i] = '('
t = 0
broke = False
for (i, c) in enumerate(seq):
	if c == '(':
		t += 1
	else:
		t -= 1
	if t <= 0:
		if i != len(seq) - 1:
			broke = True
			break
if t == 0 and (not broke):
	print(''.join(seq))
else:
	print(':(')


n = int(input())
s = input()
C0 = 0
C1 = 0
C2 = 0
L = []
flag = 0
cc0 = []
cc1 = []
for i in range(len(s) - 1, -1, -1):
	L.append(s[i])
	if s[i] == '(':
		C0 += 1
	elif s[i] == ')':
		C1 += 1
	else:
		C2 += 1
	cc0.append(C0)
	cc1.append(C1)
cc0 = cc0[::-1]
cc1 = cc1[::-1]
L = L[::-1]
c0 = 0
c1 = 0
if L[0] == '?':
	L[0] = '('
	c0 += 1
elif L[0] == ')':
	flag = 1
	c1 += 1
else:
	c0 += 1
if len(s) % 2 != 0:
	flag = 1
for i in range(1, len(L) - 1):
	if c0 <= c1:
		flag = 1
		break
	if L[i] == ')':
		c1 += 1
	elif L[i] == '(':
		c0 += 1
	elif L[i] == '?':
		if c0 > c1 + 1:
			if c0 < len(s) // 2 and c0 + cc0[i] + 1 <= len(s) // 2:
				L[i] = '('
				c0 += 1
			else:
				L[i] = ')'
				c1 += 1
		else:
			L[i] = '('
			c0 += 1
if c0 <= c1:
	flag = 1
if L[-1] == '(':
	c0 += 1
	flag = 1
elif L[-1] == ')':
	c1 += 1
else:
	L[-1] = ')'
	c1 += 1
if c0 != c1:
	flag = 1
if flag == 0:
	L = ''.join(L)
	print(L)
else:
	print(':(')


from collections import Counter
n = int(input())
s = input()
c = Counter(s)
if n & 1 or c['('] > n // 2 or c[')'] > n // 2:
	print(':(')
else:
	f1 = n // 2 - c['(']
	f2 = n // 2 - c[')']
	r = []
	for v in s:
		if v == '?':
			if f1 > 0:
				r.append('(')
				f1 -= 1
			else:
				r.append(')')
				f2 -= 1
		else:
			r.append(v)
	cnt = 0
	for (i, v) in enumerate(r):
		if v == '(':
			cnt += 1
		else:
			cnt -= 1
		if i < n - 1 and cnt <= 0:
			print(':(')
			break
	else:
		print(''.join(r))


n = int(input())
s = input()
res = [''] * n
if n % 2 == 1 or s[0] == ')' or s[n - 1] == '(':
	print(':(')
else:
	count = 0
	for (i, c) in enumerate(s):
		res[i] = c
		if c == ')':
			count += 1
	for i in range(n - 1, -1, -1):
		if s[i] == '?':
			if count < n / 2:
				res[i] = ')'
				count += 1
			else:
				res[i] = '('
	count = 0
	for (i, el) in enumerate(res):
		if count < 0 or (count == 0 and i != len(res) - 1 and (i != 0)):
			res = []
			break
		if el == '(':
			count += 1
		if el == ')':
			count -= 1
	if count == 0 and res:
		print(''.join(res))
	else:
		print(':(')


n = int(input())
a = list(input())
if n % 2:
	print(':(')
else:
	if '?' == a[0]:
		a[0] = '('
	if '?' == a[-1]:
		a[-1] = ')'
	if a[0] != '(' or a[-1] != ')':
		print(':(')
	else:
		l = n // 2 - a.count('(')
		r = n // 2 - a.count(')')
		if l < 0 or r < 0:
			print(':(')
		else:
			h = 0
			for i in range(1, n - 1):
				if '?' == a[i]:
					if l:
						a[i] = '('
						l -= 1
					elif h and r:
						a[i] = ')'
						r -= 1
				if '(' == a[i]:
					h += 1
				elif ')' == a[i]:
					h -= 1
				else:
					print(':(')
					break
				if h < 0:
					print(':(')
					break
			else:
				print(''.join(a))


def solve():
	n = int(input())
	s = list(input())
	if n % 2:
		print(':(')
		return
	cv = s.count('?')
	co = s.count('(')
	cc = s.count(')')
	b = 0
	for i in range(n):
		if s[i] == '(':
			b += 1
		elif s[i] == ')':
			b -= 1
		elif co < n // 2:
			s[i] = '('
			b += 1
			co += 1
		else:
			s[i] = ')'
			b -= 1
			cc += 1
		if b <= 0 and i != n - 1:
			print(':(')
			return
	if b != 0:
		print(':(')
		return
	print(''.join(s))
solve()


n = int(input())
s = input()
res = []
x = 0
l = r = n // 2
l -= s.count('(')
r -= s.count(')')
y = r - l
f = s.count('?')

def check(d, b):
	ans = x + d >= b
	if d == 1:
		ans &= l >= 1
	else:
		ans &= r >= 1
	ans &= -f <= -(x + y + d) <= f
	return ans
for (i, c) in enumerate(s):
	if n & 1 or l < 0 or r < 0:
		res = []
		break
	if c == '?':
		if check(1, int(i != n - 1)):
			l -= 1
			res.append('(')
		elif check(-1, int(i != n - 1)):
			r -= 1
			res.append(')')
		else:
			res = []
			break
		f -= 1
	else:
		res.append(c)
	if res[-1] == '(':
		x += 1
		if c != '?':
			y -= 1
	else:
		x -= 1
		if c != '?':
			y += 1
curr = 0
for (i, c) in enumerate(res):
	if c == '(':
		curr += 1
	else:
		curr -= 1
	if curr < 0 or (curr == 0 and i != n - 1):
		res = []
		break
if res:
	print(''.join(res))
else:
	print(':(')


def mp():
	return map(int, input().split())
n = int(input())
s = list(input())
b = 0
o = n // 2 - s.count('(')
for i in range(n):
	if s[i] == '(':
		b += 1
	elif s[i] == ')':
		b -= 1
	elif o > 0:
		s[i] = '('
		b += 1
		o -= 1
	else:
		s[i] = ')'
		b -= 1
b = 0
fail = False
for i in range(n):
	if s[i] == '(':
		b += 1
	else:
		b -= 1
	if b < 0 or (i != n - 1 and b == 0):
		fail = True
if fail or b != 0:
	print(':(')
else:
	print(''.join(s))


import math
n = int(input())
string = input()
if n % 2 != 0:
	print(':(')
else:
	ms = ''
	sum = 0
	o = 0
	c = 0
	h = n // 2
	for i in string:
		if i == '(':
			o += 1
		elif i == ')':
			c += 1
	for i in range(n):
		if sum <= 0 and i != 0:
			sum = math.inf
			break
		elif i == 0:
			if string[i] == '?':
				ms += '('
				o += 1
				sum += 1
			elif string[i] == '(':
				sum += 1
				ms += '('
			else:
				sum -= 1
				ms += ')'
		elif sum > 0 and i != 0:
			if string[i] == '?':
				if h - o > 0:
					ms += '('
					o += 1
					sum += 1
				elif h - c > 0:
					ms += ')'
					c += 1
					sum -= 1
			elif string[i] == '(':
				sum += 1
				ms += '('
			else:
				sum -= 1
				ms += ')'
	if sum == math.inf or sum != 0:
		print(':(')
	else:
		print(ms)


n = int(input())
s = list(input())
if n % 2 == 1:
	print(':(')
else:
	op = n // 2 - s.count('(')
	for i in range(n):
		if s[i] == '?':
			if op > 0:
				s[i] = '('
			else:
				s[i] = ')'
			op -= 1
	b = 0
	for i in range(n):
		if s[i] == ')':
			b -= 1
		else:
			b += 1
		if i != n - 1 and b <= 0:
			print(':(')
			break
	else:
		if b == 0:
			print(''.join(s))
		else:
			print(':(')


n = int(input())
s = list(input())
l = s.count('(')
cnt = 0
for i in range(n):
	if s[i] == '?':
		if l + l < n:
			s[i] = '('
			l += 1
		else:
			s[i] = ')'
for i in range(n):
	if s[i] == '(':
		cnt += 1
	elif s[i] == ')':
		cnt -= 1
	if cnt < 0 or (cnt != 0 and i == n - 1) or (cnt == 0 and i != n - 1):
		print(':(')
		exit(0)
print(''.join(s))


n = int(input())
s = list(input())
(l, r) = (s.count('('), s.count(')'))
for i in range(n):
	if s[i] == '?' and 2 * l < n:
		s[i] = '('
		l += 1
	elif s[i] == '?' and 2 * l >= n:
		s[i] = ')'
cnt = 0
for i in range(n):
	cnt = cnt + 1 if s[i] == '(' else cnt - 1
	if cnt <= 0 and i < n - 1 or (cnt > 0 and i == n - 1):
		print(':(')
		break
else:
	print(''.join(s) if n % 2 == 0 else ':(')


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
n = int(input())
s = list(input())
l = 0
r = 0
for i in s:
	if i == '(':
		l += 1
	elif i == ')':
		r += 1
for i in range(n):
	if s[i] == '?' and 2 * l < n:
		s[i] = '('
		l += 1
	elif s[i] == '?' and 2 * l >= n:
		s[i] = ')'
k = 0
for i in range(n):
	if s[i] == '(':
		k += 1
	else:
		k -= 1
	if k <= 0 and i < n - 1 or (k > 0 and i == n - 1):
		print(':(')
		exit()
if n % 2 == 0:
	for i in s:
		print(i, end='')
else:
	print(':(')


def readint():
	return int(input())
n = readint()
s = input()
a = 0
b = 0
for c in s:
	if c == '(':
		a += 1
	elif c == ')':
		b += 1
x = n - (a + b)
m = a - b
p = x - m
p /= 2
r = []
for c in s:
	if c == '?':
		if p:
			p -= 1
			r += '('
		else:
			r += ')'
	else:
		r.append(c)
m = 0
ok = True
for i in range(n):
	if r[i] == '(':
		m += 1
	else:
		m -= 1
	if m < 0 or (m == 0 and i != n - 1):
		ok = False
if m != 0:
	ok = False
if ok:
	print(''.join(r))
else:
	print(':(')


from sys import stdout, stdin
n = int(stdin.readline())
s = stdin.readline()
s = list(s)
B = True
if n & 1 or s[n - 1] == '(' or s[0] == ')' or (s[n - 2] == '('):
	print(':(')
else:
	op = n // 2
	cp = n // 2
	aop = 0
	acp = 0
	cop = 0
	if s[0] == '?':
		s[0] = '('
	if s[n - 1] == '?':
		s[n - 1] = ')'
	for i in s:
		if i == '(':
			aop += 1
		elif i == ')':
			acp += 1
	rcp = cp - acp
	rop = op - aop
	if rcp < 0 or rop < 0:
		print(':(')
		B = False
	else:
		a = [0 for i in range(n)]
		for i in range(n):
			if s[i] == '?':
				if rop > 0:
					a[i] = '('
					rop -= 1
				elif rcp > 0:
					a[i] = ')'
					rcp -= 1
				else:
					print(':(')
					B = False
					break
			else:
				a[i] = s[i]
			if a[i] == '(':
				cop += 1
			else:
				cop -= 1
				if cop <= 0 and i != n - 1:
					print(':(')
					B = False
					break
	if B:
		for i in a:
			print(i, end='')


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	elif p == 3:
		return list(input())
	else:
		return int(input())
n = f()
s = f(3)
b = 0
a = s.count('(')
for i in range(n):
	if s[i] == '?':
		if a < n // 2:
			s[i] = '('
			a += 1
		else:
			s[i] = ')'
	if s[i] == '(':
		b += 1
	else:
		b -= 1
	if b == 0 and i != n - 1 or b < 0 or (b != 0 and i == n - 1):
		print(':(')
		exit()
print(''.join(s))


n = int(input())
s = str(input())
s = list(s)
if n % 2 == 1:
	print(':(')
	quit()
a = b = 0
for i in s:
	if i == '(':
		a += 1
	elif i == ')':
		b += 1
a = n // 2 - a
b = n // 2 - b
for i in range(n):
	if s[i] == '?':
		if a == 0:
			s[i] = ')'
			b -= 1
		else:
			s[i] = '('
			a -= 1
c = 0
for i in range(n):
	if s[i] == '(':
		c += 1
	else:
		c -= 1
	if c < 0 or (c == 0 and i != n - 1):
		print(':(')
		quit()
if c != 0:
	print(':(')
	quit()
print(''.join(s))


n = int(input())
s = input()
(l, r) = (0, 0)
for ch in s:
	if ch == '(':
		l += 1
	elif ch == ')':
		r += 1
mid = n // 2
if n % 2 == 1 or l > mid or r > mid:
	print(':(')
	exit(0)
res = ''
cnt = 0
for i in range(n):
	ch = s[i]
	if ch == '?':
		if l < mid:
			l += 1
			ch = '('
		else:
			ch = ')'
	res += ch
	cnt += 1 if ch == '(' else -1
	if cnt < 0 or (cnt == 0 and i < n - 1):
		print(':(')
		exit(0)
print(res if cnt == 0 else ':(')


n = int(input())
state = list(input())
if ')' == state[0] or '(' == state[-1] or len(state) % 2 == 1:
	print(':(')
else:
	state[0] = '('
	state[-1] = ')'
	left_index = 1
	right_index = 1
	question_index = 1
	while left_index != len(state) - 1 and right_index != len(state) - 1 and (question_index != len(state) - 1):
		while left_index < len(state) - 1:
			if state[left_index] == ')':
				break
			left_index += 1
		if left_index == len(state) - 1:
			break
		while right_index < left_index:
			if state[right_index] == '(':
				break
			right_index += 1
		if right_index == left_index:
			while question_index < right_index:
				if state[question_index] == '?':
					break
				question_index += 1
			if question_index == right_index:
				print(':(')
				exit()
			else:
				state[question_index] = '('
		left_index += 1
		right_index += 1
		question_index += 1
	left_index = len(state) - 2
	right_index = len(state) - 2
	question_index = len(state) - 2
	while left_index != 0 and right_index != 0 and (question_index != 0):
		while right_index > 0:
			if state[right_index] == '(':
				break
			right_index -= 1
		if right_index == 0:
			break
		while right_index < left_index:
			if state[left_index] == ')':
				break
			left_index -= 1
		if right_index == left_index:
			while question_index > right_index:
				if state[question_index] == '?':
					break
				question_index -= 1
			if question_index == right_index:
				print(':(')
				exit()
			else:
				state[question_index] = ')'
		left_index -= 1
		right_index -= 1
		question_index -= 1
	next_ele = '('
	for i in range(len(state)):
		if state[i] == '?':
			state[i] = next_ele
			next_ele = ')' if next_ele == '(' else '('
	print(''.join(state))


n = int(input())
s = list(input())
l = 0
r = 0
for i in range(n):
	if s[i] == '(':
		r += 1
	elif s[i] == ')':
		l += 1
x = n - l - r
g = r - l
ee = (x - abs(g)) // 2
t = 0
for i in range(n):
	if s[i] == '?':
		if t < ee:
			s[i] = '('
			t += 1
		elif t >= ee + abs(g):
			s[i] = ')'
		else:
			if g > 0:
				s[i] = ')'
			else:
				s[i] = '('
			t += 1
ff = 0
for i in s[:-1]:
	if i == '(':
		ff += 1
	else:
		ff -= 1
	if ff <= 0:
		print(':(')
		exit()
if s[-1] == ')':
	ff -= 1
else:
	ff += 1
if ff != 0:
	print(':(')
	exit()
print(*s, sep='')


n = int(input())
s = list(input())
a = s.count('(')
b = 0
for i in range(len(s)):
	if s[i] == '?':
		if a < n // 2:
			s[i] = '('
			a += 1
		else:
			s[i] = ')'
	b += 1 if s[i] == '(' else -1
	if b <= 0 and i != n - 1:
		print(':(')
		raise SystemExit
print(':(' if b != 0 else ''.join(s))


def solve(s):
	op = len(s) // 2
	cl = len(s) // 2
	for i in range(len(s)):
		if s[i] == '(':
			op -= 1
		elif s[i] == ')':
			cl -= 1
	res = list(s)
	pcl = pop = 0
	for i in range(len(s) - 1, -1, -1):
		if s[i] == '?':
			if cl > 0:
				res[i] = ')'
				cl -= 1
				pcl += 1
			else:
				res[i] = '('
				op -= 1
				pop += 1
		if s[i] == '(':
			pop += 1
		if s[i] == ')':
			pcl += 1
		if pcl == pop and i > 0:
			return ':('
	seq = ''.join(res)
	if check_seq(seq):
		return seq
	else:
		return ':('

def check_seq(seq):
	q = 0
	for ch in seq:
		if ch == '(':
			q += 1
		else:
			q -= 1
			if q < 0:
				return False
	return q == 0
letters = int(input())
seq = solve(input())
print(seq)


n = int(input())
s = input()
if n % 2:
	print(':(')
else:
	k = ''
	b = [0] * n
	open1 = 0
	close1 = 0
	ind = n
	mn = 10 ** 9
	open2 = 0
	close2 = 0
	for i in range(n):
		if s[i] == ')':
			close1 += 1
		elif s[i] == '(':
			open1 += 1
	for i in range(n):
		if s[i] == '?':
			if open1 < n // 2:
				k += '('
				open1 += 1
				open2 += 1
			else:
				k += ')'
				close1 += 1
				close2 += 1
		else:
			k += s[i]
			if k[i] == ')':
				close2 += 1
			else:
				open2 += 1
		b[i] = open2 - close2
		if b[i] == 0:
			ind = min(ind, i)
		mn = min(b[i], mn)
	if ind == n - 1 and mn == 0:
		print(k)
	else:
		print(':(')


n = int(input())
st = list(input())
if n % 2 == 1:
	print(':(')
else:
	open = st.count('(')
	close = 0
	if open > n // 2:
		print(':(')
	else:
		for e in range(len(st)):
			if st[e] == '?':
				if open < n / 2:
					st[e] = '('
					open += 1
				else:
					st[e] = ')'
		op = 0
		cl = 0
		for e in range(len(st)):
			if st[e] == '(':
				op += 1
			elif st[e] == ')':
				cl += 1
			if cl >= op and e != 0 and (e != len(st) - 1):
				print(':(')
				exit(0)
		print(''.join(st))


import sys
n = int(input())
s = input()
if n % 2 == 1 or s[0] == ')' or s[-1] == '(':
	print(':(')
	sys.exit(0)
n -= 2
s = s[1:-1]
mas = []
kol1 = 0
kol2 = 0
for i in range(n):
	if s[i] == '?':
		mas.append(0)
	elif s[i] == '(':
		mas.append(-1)
		kol1 += 1
	else:
		mas.append(1)
		kol2 += 1
if max(kol1, kol2) * 2 > n:
	print(':(')
	sys.exit(0)
x = 0
y = 0
if kol1 > kol2:
	x = n // 2 - kol1
	y = kol1 - kol2 + n // 2 - kol1
else:
	x = kol2 - kol1 + n // 2 - kol2
	y = n // 2 - kol2
for i in range(n):
	if mas[i] != 0:
		continue
	if x > 0:
		mas[i] = -1
		x -= 1
	else:
		mas[i] = 1
kol = 0
for i in range(n):
	kol += mas[i]
	if kol > 0:
		print(':(')
		sys.exit(0)
print('(', end='')
for i in range(n):
	if mas[i] == -1:
		print('(', end='')
	else:
		print(')', end='')
print(')')


import sys
from math import ceil

def bad():
	print(':(')
	sys.exit()
n = int(input())
par = list(input())
s = 0
q = 0
for i in range(len(par)):
	if par[i] == '(':
		s += 1
	elif par[i] == ')':
		s -= 1
	elif par[i] == '?':
		q += 1
a = (q - s) // 2
b = q - a
s = 0
for i in range(len(par)):
	if par[i] == '?':
		if a > 0:
			par[i] = '('
			a -= 1
		else:
			par[i] = ')'
			b -= 1
	if par[i] == '(':
		s += 1
	elif par[i] == ')':
		s -= 1
	if s <= 0 and i < len(par) - 1:
		bad()
if s == 0:
	print(''.join(par))
else:
	bad()


sctype = {'(': 0, ')': 1, '?': -1}
ln = int(input())
s = list(input())
if s[0] == ')' or ln % 2 == 1:
	print(':(')
	exit()
s[0] = '('
opp = 0
opl = 1
op = []
r = True
pspt = [0, 0]
for i in range(ln):
	if sctype[s[i]] == -1:
		opl += 1
	else:
		pspt[sctype[s[i]]] += 1
		op.append([opp, opl, list(pspt)])
		opp = i
		opl = 0
op.append([ln, opl, [max(pspt), max(pspt)]])
nado = ln - max(pspt) * 2
nop = max(0, pspt[1] - pspt[0]) + nado // 2
ncl = max(0, pspt[0] - pspt[1]) + nado // 2
opp = -1
pspt = [0, 0]
for i in range(ln):
	if sctype[s[i]] == -1:
		if nop > 0:
			nop -= 1
			pspt[0] += 1
			s[i] = '('
		elif ncl > 0:
			ncl -= 1
			s[i] = ')'
			pspt[1] += 1
		else:
			r = False
	else:
		opp += 1
		pspt[sctype[s[i]]] += 1
	if pspt[0] == pspt[1] and i + 1 != ln:
		r = False
		break
if r and pspt[0] == pspt[1]:
	print(*s, sep='')
else:
	print(':(')


n = int(input())
my_str = input()
strl = list(my_str)
num = [0] * n
if n % 2:
	print(':(')
	exit()
for i in range(n - 2, 0, -1):
	num[i] = num[i + 1]
	if strl[i] == '(':
		num[i] = num[i] + 1
l = 0
s = 0
for i in range(n):
	if strl[i] == '(':
		l = l + 1
		s = s + 1
	elif strl[i] == ')':
		if l > 0:
			l = l - 1
			if l == 0 and i != n - 1:
				print(':(')
				exit()
		else:
			print(':(')
			exit()
	else:
		if s + num[i] < n // 2:
			l = l + 1
			s = s + 1
			strl[i] = '('
		else:
			strl[i] = ')'
			l = l - 1
		if l <= 0 and i != n - 1:
			print(':(')
			exit()
if s != n // 2:
	print(':(')
	exit()
realstr = []
realstr = ''.join(strl)
print(realstr)


import sys, math, queue
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

def ok(x):
	stack = 1
	for i in range(1, len(x)):
		if x[i] == '(':
			stack += 1
		elif stack == 0:
			return ':('
		else:
			stack -= 1
		if stack == 0 and i != len(x) - 1:
			return ':('
	if stack == 0:
		return ''.join(x)
	else:
		return ':('
n = int(input())
s = list(input())
if s[0] == ')' or s[-1] == '(' or n & 1 == 1:
	print(':(')
	exit()
if s[0] == '?':
	s[0] = '('
if s[-1] == '?':
	s[-1] = ')'
op = 0
cl = 0
for i in range(n):
	if s[i] == '(':
		op += 1
	elif s[i] == ')':
		cl += 1
if op > n // 2 or cl >> n // 2:
	print(':(')
	exit()
op = n // 2 - op
for i in range(n):
	if s[i] == '?':
		if op > 0:
			s[i] = '('
			op -= 1
		else:
			s[i] = ')'
print(ok(s))


input()
s = input()
if len(s) & 1:
	print(':(')
	raise SystemExit(0)
(max_open, min_open) = (0, 0)
started = False
q_mark = 0
op = 0
cl = 0
ended = False
for c in s:
	if ended:
		print(':(')
		raise SystemExit(0)
	if min_open <= 0 and started:
		min_open = 1
	started = True
	if c == '(':
		op += 1
		max_open += 1
		min_open += 1
	elif c == ')':
		cl += 1
		max_open -= 1
		min_open -= 1
	else:
		q_mark += 1
		max_open += 1
		min_open -= 1
	if max_open < 1:
		ended = True
if min_open != 0:
	print(':(')
	raise SystemExit(0)
s = list(s)
open_count = len(s) // 2 - op
for i in range(len(s)):
	if s[i] == '(':
		op -= 1
	elif s[i] == ')':
		cl -= 1
	elif s[i] == '?':
		if open_count == 0:
			s[i] = ')'
		else:
			s[i] = '('
			open_count -= 1
print(''.join(s))


N = int(input())
S = input()
left = S.count('(')
right = S.count(')')
plus = 0
ans = ''
for i in range(N):
	if S[i] == '?':
		if left < N // 2:
			ans += '('
			plus += 1
			left += 1
		else:
			ans += ')'
			plus -= 1
			right += 1
	elif S[i] == '(':
		ans += '('
		plus += 1
	else:
		ans += ')'
		plus -= 1
	if i != N - 1 and plus <= 0:
		print(':(')
		exit()
if left == right == N // 2:
	print(ans)
else:
	print(':(')
	exit()


import sys

def main():
	inp = sys.stdin.read().split()
	ii = 0
	n = int(inp[ii])
	ii += 1
	s = list(inp[ii])
	if n % 2:
		print(':(')
		sys.exit()
	a = n // 2 - s.count('(')
	b = n // 2 - s.count(')')
	if a < 0 or b < 0:
		print(':(')
		sys.exit()
	for i in range(n):
		if s[i] == '?':
			if a:
				s[i] = '('
				a -= 1
			else:
				s[i] = ')'
				b -= 1
	check = 0
	bad = False
	for i in range(n - 1):
		if s[i] == '(':
			check += 1
		else:
			check -= 1
		if check <= 0:
			bad = True
			break
	if bad:
		print(':(')
	else:
		print(''.join(s))
main()


def solve():
	if n % 2:
		return ':('
	c = 0
	op = 0
	for i in range(n):
		if s[i] == '(':
			op += 1
	for i in range(n):
		if op == n // 2:
			break
		if s[i] == '?':
			s[i] = '('
			op += 1
	for i in range(n):
		if i != 0 and c <= 0:
			return ':('
		if s[i] == '(':
			c += 1
		elif s[i] == ')':
			c -= 1
		else:
			s[i] = ')'
			c -= 1
	if c == 0:
		return ''.join(s)
	else:
		return ':('
n = int(input())
s = list(input())
print(solve())


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def solution():
	n = int(input())
	l = list(input())
	a = 0
	b = 0
	if n % 2 != 0:
		print(':(')
		return
	for i in range(n):
		if l[i] == '(':
			a += 1
		elif l[i] == ')':
			b += 1
	for i in range(n):
		if a >= n // 2:
			break
		if l[i] == '?':
			a += 1
			l[i] = '('
	for i in range(n - 1, -1, -1):
		if b >= n // 2:
			break
		if l[i] == '?':
			b += 1
			l[i] = ')'
	ans = 0
	for i in range(n):
		if l[i] == '(':
			ans += 1
		else:
			ans -= 1
		if ans < 0:
			print(':(')
			return
		if i != n - 1 and ans == 0:
			print(':(')
			return
	if ans == 0:
		print(''.join(l))
	else:
		print(':(')
t = 1
for _ in range(t):
	solution()


l = int(input())
str = input()
str_list = []
cur_open = 0
cur_close = 0
start = -1
cur = 0

def find(str_list, open_cur, close_cur):
	for i in range(len(str_list)):
		if str_list[i] == '?':
			if 2 * open_cur == len(str_list):
				str_list[i] = ')'
			else:
				str_list[i] = '('
				open_cur += 1

def check(str_list):
	cur = 0
	for i in range(len(str_list)):
		char = str_list[i]
		if char == '(':
			cur += 1
		else:
			cur -= 1
		if cur == 0 and i != len(str_list) - 1 or cur < 0:
			return False
	if cur != 0:
		return False
	return True
total = 0
open_cur = 0
close_cur = 0
for i in range(len(str)):
	char = str[i]
	if char == '(':
		open_cur += 1
	elif char == ')':
		close_cur += 1
	else:
		total += 1
	str_list.append(char)
if total > 0:
	find(str_list, open_cur, close_cur)
r = check(str_list)
if r == False:
	print(':(')
else:
	print(''.join(str_list))