Petya's friends made him a birthday present — a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to fix present himself. 

To make everything right, Petya is going to move at most one bracket from its original place in the sequence to any other position. Reversing the bracket (e.g. turning "(" into ")" or vice versa) isn't allowed. 

We remind that bracket sequence $s$ is called correct if:   $s$ is empty;  $s$ is equal to "($t$)", where $t$ is correct bracket sequence;  $s$ is equal to $t_1 t_2$, i.e. concatenation of $t_1$ and $t_2$, where $t_1$ and $t_2$ are correct bracket sequences. 

For example, "(()())", "()" are correct, while ")(" and "())" are not. Help Petya to fix his birthday present and understand whether he can move one bracket so that the sequence becomes correct.


-----Input-----

First of line of input contains a single number $n$ ($1 \leq n \leq 200\,000$) — length of the sequence which Petya received for his birthday.

Second line of the input contains bracket sequence of length $n$, containing symbols "(" and ")".


-----Output-----

Print "Yes" if Petya can make his sequence correct moving at most one bracket. Otherwise print "No".


-----Examples-----
Input
2
)(

Output
Yes

Input
3
(()

Output
No

Input
2
()

Output
Yes

Input
10
)))))(((((

Output
No



-----Note-----

In the first example, Petya can move first bracket to the end, thus turning the sequence into "()", which is correct bracket sequence.

In the second example, there is no way to move at most one bracket so that the sequence becomes correct.

In the third example, the sequence is already correct and there's no need to move brackets.

Difficulty: EASY

Solutions:
import sys
import bisect
from collections import deque
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

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 INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
n = int(ri())
st = ri()
summ = 0
ans = 0
tot = 0
for i in range(n):
	if st[i] == '(':
		summ += 1
		tot += 1
	else:
		summ -= 1
		tot -= 1
	if summ < 0:
		ans += 1
		summ = 0
if tot != 0:
	No()
elif ans > 1:
	No()
else:
	Yes()


def read():
	n = int(input())
	s = input()
	return (n, s)

def solve(n, s):
	st = [s[0]]
	for i in range(1, n):
		if s[i] == '(':
			st.append(s[i])
		elif len(st) == 0:
			st.append(s[i])
		elif st[-1] == '(':
			st.pop()
		else:
			st.append(s[i])
	if len(st) == 0:
		return True
	elif len(st) == 2:
		return st[0] != st[1]
result = solve(*read())
print('Yes' if result else 'No')


input()
s = input()
e = 0
ok = True
for v in s:
	if v == '(':
		e += 1
	elif v == ')':
		e -= 1
	if e < -1:
		ok = False
print('Yes' if ok and e == 0 else 'No')


b = int(input())
st = input()
ans = 0
fl = 0
for c in st:
	if len(st) % 2 == 1:
		fl = 1
		print('No')
		break
	if c == '(':
		ans += 1
	if c == ')':
		ans -= 1
	if ans == -2:
		fl = 1
		print('No')
		break
if fl == 0 and ans == 0:
	print('Yes')
elif fl == 0 and ans != 0:
	print('No')


n = int(input())
s = input()
depth = 0
ig = False
for i in range(n):
	if not ig and s[i] == ')':
		ig = True
		continue
	if s[i] == '(':
		depth += 1
	else:
		depth -= 1
	if depth < 0:
		print('No')
		return
if ig:
	depth -= 1
if depth:
	print('No')
else:
	print('Yes')


n = int(input())
string = input().strip()
if string.count('(') != string.count(')'):
	print('No')
else:
	(lcount, rcount) = (0, 0)
	flag = 1
	for i in string:
		if i == '(':
			lcount += 1
		if i == ')':
			rcount += 1
		if rcount - lcount > 1:
			flag = 0
			break
	if flag == 1:
		print('Yes')
	else:
		print('No')


from sys import stdin

def sin():
	return stdin.readline()
n = int(sin())
s = sin()
if n % 2 != 0:
	print('No')
else:
	t = 1
	for i in s:
		if i == ')':
			t -= 1
		elif i == '(':
			t += 1
		if t < 0:
			break
	if t == 0 or t == 1:
		print('Yes')
	else:
		print('No')


n = int(input())
s = list(input())
if n % 2 == 1:
	print('No')
	exit()
s = [0 if x == '(' else 1 for x in s]
if sum(s) != n // 2:
	print('No')
	exit()
count = 0
for i in range(n):
	if s[i] == 0:
		count += 1
	else:
		count -= 1
	if count <= -2:
		print('No')
		exit()
print('Yes')


import sys
Lines = []
for Line in sys.stdin:
	Lines.append(Line.rstrip('\n'))
n = int(Lines[0])
del Lines[0]
t = Lines[0]
stack = []
stack2 = []
nb_ouv = t.count('(')
if nb_ouv != n - nb_ouv:
	print('No')
	exit(0)
for p in t:
	if p == '(':
		stack += ['(']
	elif p == ')':
		if len(stack) != 0:
			stack.pop(0)
		else:
			stack2 += [')']
if len(stack) < 2 and len(stack2) < 2:
	print('Yes')
else:
	print('No')


n = int(input())
s = list(input())
stack = []
for (i, num) in enumerate(s):
	if len(stack) == 0:
		stack.append(num)
	elif stack[-1] == '(' and num == ')':
		stack.pop()
	else:
		stack.append(num)
if len(stack) == 2 and stack[0] != stack[1] or len(stack) == 0:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
s = list(s)
l = 0
r = 0
p = 0
k = []
for i in s:
	if i == '(':
		l += 1
		k.append(i)
	else:
		r += 1
		if len(k) > 0:
			k.pop()
			p += 1
if l == r and (l - 1 == p or l == p):
	print('Yes')
else:
	print('No')


n = int(input())
b = str(input())
stack = ['' for i in range(n)]
top = 0
for i in range(n):
	if len(stack) == 0:
		stack[top] = b[i]
		continue
	if b[i] == '(':
		stack[top] = b[i]
		top += 1
	elif b[i] == ')':
		if stack[top - 1] == '(':
			top -= 1
		else:
			stack[top] = ')'
			top += 1
if top == 0 or (top == 2 and stack[0] == ')' and (stack[1] == '(')):
	print('Yes')
else:
	print('No')


n = int(input())
a = list(input())
x = 0
flag = 0
for i in range(n):
	if a[i] == '(':
		x += 1
	elif x > -1:
		x -= 1
	else:
		flag = 1
		break
if flag == 1 or x != 0:
	print('No')
else:
	print('Yes')


(n, s) = (int(input()), input())
nums_o = s.count('(')
nums_c = s.count(')')
if n % 2 or nums_c != nums_o:
	print('No')
else:
	cnt = 0
	stack = []
	for c in s:
		if c == '(':
			stack.append(c)
		elif len(stack) != 0:
			stack.pop()
		else:
			cnt += 1
			if cnt == 2:
				print('No')
				break
	else:
		print('Yes')


num = int(input())
if num % 2 == 1:
	print('No')
	exit()
bracket = list(input())
st = bracket[0]
stack = []
one = 0
two = 0
for (i, a) in enumerate(bracket):
	if a == '(':
		one += 1
		stack.append([a, i])
	else:
		two += 1
		if stack:
			check = stack.pop()
			bracket[i] = '_'
			bracket[check[1]] = '_'
if one != two:
	print('No')
	exit()
s = ''
i = 0
while i < len(bracket):
	if bracket[i] != '_':
		s += bracket[i]
	i += 1
if len(s) <= 2:
	print('Yes')
else:
	print('No')


n = int(input())
str = input()
bal = 0
for i in range(n):
	bal += 1
	if str[i] == ')':
		bal -= 2
	if bal < -1:
		print('No')
		break
else:
	print('Yes' if bal == 0 else 'No')


n = int(input())
inp = input()
arr = []
m = 0
if n % 2 != 0:
	print('No')
else:
	for i in inp:
		if i == '(':
			arr.append('(')
		elif i == ')':
			if arr:
				arr.pop()
			else:
				m += 1
	if m == 1 and len(arr) == 1 or (m == 0 and len(arr) == 0):
		print('Yes')
	else:
		print('No')


n = int(input())
s = input()
if 2 * s.count('(') != n:
	print('No')
	exit(0)
b = 0
f = False
(kz, kkz) = (0, 0)
for i in range(n):
	if s[i] == '(':
		b += 1
	else:
		b -= 1
	if b == -1 and (not f):
		b = 0
		f = True
	if f:
		if b == 0:
			kz = i
		elif b > 0:
			kkz = i
		else:
			print('No')
			exit(0)
if kkz > kz or not f:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
mnl = 0
cntl = 0
for i in range(n):
	if s[i] == '(':
		cntl += 1
	else:
		cntl -= 1
	mnl = min(cntl, mnl)
	if mnl <= -2:
		print('No')
		exit()
if cntl != 0:
	print('No')
else:
	print('Yes')


input()
s = input()
b = 0
min_b = 0
for i in range(len(s)):
	if s[i] == '(':
		b += 1
	else:
		b -= 1
	min_b = min(min_b, b)
if min_b >= -1 and b == 0:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
stack = []
l = 0
r = 0
cnt = 0
for i in s:
	if i == '(':
		stack.append('(')
		l += 1
	else:
		if len(stack) > 0:
			stack.pop(-1)
		else:
			cnt += 1
		r += 1
if len(stack) == 0 and abs(l - r) == 0 or (abs(l - r) == 0 and l == 1):
	print('Yes')
elif len(stack) == 1 and cnt == 1:
	print('Yes')
else:
	print('No')


b = int(input())
g = input()
n = 0
m = 0
e = 0
for i in g:
	if i == '(':
		n += 1
	elif i == ')' and n == m:
		e += 1
	else:
		m += 1
if e <= 1 and n == m + e:
	print('Yes')
else:
	print('No')


from collections import Counter
n = int(input())
bra = input()
d = Counter(bra)
ans = 0
if d['('] == d[')']:
	c = 0
	for i in bra:
		if i == '(':
			c += 1
		elif c == 0:
			ans += 1
		else:
			c -= 1
	if ans <= 1:
		print('Yes')
	else:
		print('No')
else:
	print('No')


n = int(input())
s = input()
cur = 0
chk = True
for i in range(n):
	if s[i] == ')':
		cur -= 1
	else:
		cur += 1
	if cur < -1:
		chk = False
print('Yes' if chk == True and cur == 0 else 'No')


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

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

def addDictList(d, key, val):
	if key not in d:
		d[key] = []
	d[key].append(val)

def addDictInt(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] = val

def addDictCount(d, key):
	if key not in d:
		d[key] = 0
	d[key] += 1

def addDictSum(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] += val
n = getInt()
s = getStr()
if n % 2 == 1:
	r = 'No'
else:
	r = 'Yes'
	num = 0
	for i in range(n):
		if s[i] == '(':
			num += 1
		else:
			num -= 1
			if num < -1:
				r = 'No'
				break
	if num != 0:
		r = 'No'
print(r)


li = []
n = int(input())
s = input()
a = s.count('(')
b = s.count(')')
if a != b:
	flag = 'No'
else:
	for i in s:
		if i == '(':
			li.append(1)
		elif i == ')':
			if len(li) > 0 and li[-1] == 1:
				li.pop()
			elif len(li) == 0:
				li.append(2)
	if len(li) <= 2:
		flag = 'Yes'
	else:
		flag = 'No'
print(flag)


t = 1
for _ in range(t):
	n = int(input())
	a = input()
	stack = []
	(o, c) = (0, 0)
	flag = 0
	for i in a:
		if i == '(':
			stack.append(i)
			o += 1
		else:
			if stack:
				stack.pop()
			else:
				flag += 1
			c += 1
	if o != c:
		print('No')
	elif not stack:
		print('Yes')
	elif flag == 1:
		print('Yes')
	else:
		print('No')


def check(s):
	bal = 0
	for i in range(len(s)):
		if s[i] == '(':
			bal += 1
		elif s[i] == ')':
			bal -= 1
		if bal < 0:
			return False
	for i in range(len(s) - 1, -1, -1):
		if s[i] == '(':
			bal += 1
		elif s[i] == ')':
			bal -= 1
		if bal > 0:
			return False
	if bal == 0:
		return True
	else:
		return False

def check2(s):
	bal = 0
	for i in range(len(s)):
		if s[i] == '(':
			bal += 1
		elif s[i] == ')':
			bal -= 1
		if bal < -1:
			return False
	for i in range(len(s) - 1, -1, -1):
		if s[i] == '(':
			bal += 1
		elif s[i] == ')':
			bal -= 1
		if bal > 1:
			return False
	if bal == 0:
		return True
	else:
		return False

def func():
	n = int(input())
	s = input()
	if len(s) % 2 != 0:
		print('No')
		return
	if check(s) and check2(s):
		print('Yes')
		return
	elif check2(s):
		print('Yes')
		return
	print('No')
func()


n = int(int(input()))
s = input()
if len(s) == 0:
	print('Yes')
elif s.count('(') != s.count(')'):
	print('No')
else:
	left = 0
	right = 0
	c = 0
	for i in s:
		if i == '(':
			left += 1
		elif left > 0:
			left -= 1
		else:
			c += 1
	if left == 0 and c == 0:
		print('Yes')
	elif left == 1 and c == 1:
		print('Yes')
	else:
		print('No')


n = int(input())
s = input()
br = 0
br_close = 0
flag = True
i = 0
if n % 2 == 1:
	flag = False
while i < n and flag:
	if s[i] == '(':
		br += 1
	elif s[i] == ')':
		br -= 1
	if br + 1 < 0 and flag:
		flag = False
	i += 1
if flag and br == 0:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
l = []
for i in s:
	if len(l) > 0 and i == ')' and (l[-1] == '('):
		l.pop()
	else:
		l.append(i)
if len(l) == 2 and '(' in l and (')' in l) or len(l) == 0:
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	s = input().rstrip()
	t = [0] * n
	first = -1
	for (i, c) in enumerate(s):
		if i > 0:
			t[i] += t[i - 1]
		t[i] += 1 if c == '(' else -1
		if t[i] < 0 and first == -1:
			first = i
	if first == -1:
		if t[n - 1] == 0:
			print('Yes')
		else:
			print('No')
	else:
		t = [0] * n
		for i in range(first + 1, n):
			t[i] += t[i - 1]
			t[i] += 1 if s[i] == '(' else -1
			if t[i] < 0:
				print('No')
				return
		if t[n - 1] == 1:
			print('Yes')
		else:
			print('No')
main()


n = int(input())
s = input()
stk = []
for i in range(n):
	if len(stk) > 0 and s[i] == ')':
		if stk[-1] == ')':
			stk.append(')')
		else:
			stk.pop(-1)
	else:
		stk.append(s[i])
ans = 'No'
if len(stk) == 2:
	stk.sort()
	if stk == ['(', ')']:
		ans = 'Yes'
elif len(stk) == 0:
	ans = 'Yes'
print(ans)


n = int(input())
s = input()
if s.count('(') != s.count(')'):
	print('No')
	exit()
stk = []
karma = 0
f = 1
ans = 1
for i in s:
	if i == '(':
		stk.append(i)
	elif not stk:
		f = 0
		if not karma:
			karma = 1
		else:
			ans = 0
			break
	else:
		stk.pop()
if ans and len(stk) == 1 and (stk[0] == '('):
	print('Yes')
	exit()
if not stk and f:
	f = 1
if f:
	print('Yes')
	exit()
if not ans:
	print('No')
	exit()


n = int(input())
s = input()
count = 0
res = ''
for i in s:
	if i == '(':
		count += 1
	else:
		count -= 1
	if count < -1:
		res = 'No'
		break
if res == '':
	if count == 0:
		res = 'Yes'
	else:
		res = 'No'
print(res)


n = int(input())
a = str(input())
q = 0
w = 0
i = 0
while i < n:
	if a[i] == '(':
		q += 1
	else:
		w += 1
	if w > q + 1:
		break
	else:
		i += 1
if i == n and w == q:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if n % 2 == 1:
	print('No')
else:
	bal = 0
	for i in range(n):
		if s[i] == '(':
			bal += 1
		else:
			bal -= 1
	if bal != 0:
		print('No')
	else:
		st = []
		for c in s:
			if c == '(':
				st.append(c)
			elif len(st) > 0:
				st.pop()
		if len(st) <= 1:
			print('Yes')
		else:
			print('No')


import sys
import collections
import functools
n = int(input().strip())
s = input().strip()
(stack, s2) = ([], [])
for i in s:
	if i == '(':
		stack.append(i)
	elif i == ')' and stack and (stack[-1] == '('):
		stack.pop()
	else:
		s2.append(i)
if len(s2) == 1 and s2[-1] == ')' and (len(stack) == 1) and (stack[-1] == '('):
	print('Yes')
elif len(s2) == 0 and len(stack) == 0:
	print('Yes')
else:
	print('No')


n = int(input())
q = input()
l = 0
p = 0
for i in range(len(q)):
	if q[i] == ')':
		if p > 0:
			p -= 1
		else:
			l += 1
	if q[i] == '(':
		p += 1
if p == l and p < 2:
	print('Yes')
else:
	print('No')


n = int(input())
S = input()
Stack = [S[0]]
for i in range(1, n):
	if len(Stack) == 0:
		Stack.append(S[i])
	elif Stack[-1] + S[i] == '()':
		del Stack[-1]
	else:
		Stack.append(S[i])
if len(Stack) == 0:
	print('Yes')
elif len(Stack) == 1:
	print('No')
elif Stack[0] == ')' and Stack[1] == '(' and (len(Stack) == 2):
	print('Yes')
else:
	print('No')


n = int(input())
S = input()
cnt = 0
if S.count('(') != S.count(')'):
	print('No')
	exit()
for i in range(n):
	if S[i] == '(':
		cnt += 1
	elif S[i] == ')':
		cnt -= 1
	if cnt <= -2:
		print('No')
		break
else:
	print('Yes')


import sys
n = int(input())
s = input().strip()
if n % 2 == 1:
	print('No')
	sys.exit()
sum_bracket = 0
for i in s:
	if i == ')':
		sum_bracket -= 1
	if i == '(':
		sum_bracket += 1
	if sum_bracket < -1:
		print('No')
		sys.exit(0)
if sum_bracket == 0:
	print('Yes')
else:
	print('No')


for t in range(1):
	n = int(input())
	arr = list(input())
	counter = 0
	gb_counter = 0
	if n % 2 == 1:
		print('No')
		continue
	for i in arr:
		if i == ')':
			counter -= 1
		else:
			counter += 1
		gb_counter = min(gb_counter, counter)
	if gb_counter >= -1 and counter == 0:
		print('Yes')
	else:
		print('No')


from itertools import accumulate
n = int(input())
s = [1 if c == '(' else -1 for c in input()]
res = sum(s) == 0
if res:
	l = [*accumulate(s)]
	m = min(l)
	res &= m >= -1
print('Yes' if res else 'No')


def funcc(n, s):
	cnt = 0
	i = 0
	if n % 2 != 0:
		return 'No'
	else:
		while i < n:
			if s[i] == '(':
				cnt += 1
			else:
				cnt -= 1
			if cnt < -1:
				break
			i += 1
	if cnt == 0:
		return 'Yes'
	else:
		return 'No'
n = int(input())
s = str(input())
print(funcc(n, s))


from sys import stdin
n = int(stdin.readline().strip())
s = list(stdin.readline().strip())
dp1 = [0 for i in range(n)]
dp2 = [0 for i in range(n)]
x = -1
y = -1
for i in range(n):
	if s[i] == '(':
		dp1[i] += 1
	else:
		dp1[i] -= 1
	if i > 0:
		dp1[i] += dp1[i - 1]
for i in range(n - 1, -1, -1):
	if s[i] == '(':
		dp2[i] += 1
	else:
		dp2[i] -= 1
	if i < n - 1:
		dp2[i] += dp2[i + 1]
flag = True
mn = min(dp1)
mx = max(dp2)
if mn >= -1 and mx <= 1 and (dp1[-1] == 2 or dp1[-1] == -2 or dp1[-1] == 0):
	print('Yes')
else:
	print('No')


n = int(input())
strr = input()

def solve(strr):
	open_stack = []
	close_stack = []
	for ele in strr:
		if ele == '(':
			open_stack.append('(')
		elif open_stack:
			open_stack.pop()
		else:
			close_stack.append(')')
	return len(open_stack) == 0 and len(close_stack) == 0 or (len(open_stack) == 1 and len(close_stack) == 1)
print('Yes' if solve(strr) else 'No')


def authors(n, s):
	b = 0
	if n % 2 == 0:
		ans = True
		for i in s:
			if i == '(':
				b -= 1
			else:
				b += 1
			if b > 1:
				ans = False
				break
		if b < 0:
			ans = False
	else:
		ans = False
	return ans
n = int(input())
s = input()
if authors(n, s):
	print('Yes')
else:
	print('No')


n = int(input())
x = input()
c = 0
a = x.count('(')
b = x.count(')')
if a == b:
	if n == 1:
		print('No')
	else:
		for i in range(n):
			if c >= -1:
				if x[i] == '(':
					c = c + 1
				else:
					c = c - 1
				if i == n - 1:
					print('Yes')
			elif i == n - 1:
				print('No')
else:
	print('No')


n = int(input())
s = input()
cur = 0
for ch in s:
	if ch == '(':
		cur += 1
	else:
		cur -= 1
	if cur == -2:
		print('No')
		return
print('Yes' if cur == 0 else 'No')


n = int(input())
s = input()
opening_brackets = 0
closing_brackets = 0
answer_no = False
for ch in s:
	if ch == '(':
		opening_brackets += 1
	elif opening_brackets > 0:
		opening_brackets -= 1
	elif closing_brackets == 0:
		closing_brackets = 1
	else:
		answer_no = True
		break
if answer_no:
	print('No')
elif opening_brackets == 1 and closing_brackets == 1:
	print('Yes')
elif opening_brackets > 0 or closing_brackets > 0:
	print('No')
else:
	print('Yes')


n = int(input())
brackets = list(input())
count = 0
matches = 0
for i in brackets:
	if i == '(':
		count += 1
	else:
		count -= 1
	matches = min(matches, count)
print('Yes' if matches >= -1 and count == 0 else 'No')


a = int(input())
b = input()
j = 0
if a % 2 == 0:
	for c in b:
		if c == '(':
			j += 1
		else:
			j -= 1
		if j < -1:
			break
	if j != 0:
		print('No')
	else:
		print('Yes')
else:
	print('No')


n = int(input())
s = input()
c_op = 0
er = 0
if n % 2 != 0:
	print('No')
	exit()
for i in s:
	if i == '(':
		c_op += 1
	if i == ')' and c_op > 0:
		c_op -= 1
	elif i == ')' and c_op == 0:
		er += 1
if er == 0 and c_op == 0 or (er == 1 and c_op == 1):
	print('Yes')
else:
	print('No')


from collections import defaultdict

def main():
	n = int(input())
	dados = input()
	if n % 2 != 0:
		print('No', end='')
		exit()
	qtds = defaultdict(int)
	for x in dados:
		qtds[x] += 1
		if qtds[')'] - qtds['('] >= 2:
			print('No', end='')
			exit()
	if qtds[')'] - qtds['('] != 0:
		print('No', end='')
	else:
		print('Yes', end='')
main()


n = int(input())
s = input()
if n % 2 == 1:
	print('No')
	exit()
top = 0
cntl = 0
cntr = 0
for c in s:
	if c == '(':
		top += 1
		cntl += 1
	else:
		top = max(top - 1, 0)
		cntr += 1
if top <= 1 and cntl == cntr:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
c = 0
r = 0
for i in range(len(s)):
	if s[i] == '(':
		c += 1
	else:
		c -= 1
	if c < -1:
		r = 1
		print('No')
		break
if r != 1 and c == 0:
	print('Yes')
elif r != 1:
	print('No')


n = int(input())
s = input()
x = y = 0
l = 0
ll = 0
if n % 2 != 0:
	print('No')
else:
	for i in range(n):
		if s[i] == '(':
			x += 1
			l += 1
		else:
			if l == 0:
				ll += 1
			else:
				l -= 1
			y += 1
	if n // 2 != x:
		print('No')
	elif ll > 1:
		print('No')
	elif ll == 1 and l == 1:
		print('Yes')
	else:
		print('Yes')


n = int(input())
line = input()
stack = []
count = 0
for i in range(n):
	if line[i] == '(':
		stack.append(line[i])
	elif line[i] == ')':
		if len(stack) == 0:
			count += 1
		else:
			stack.pop()
if count != len(stack):
	print('No')
elif count <= 1:
	print('Yes')
else:
	print('No')


import sys
n = int(input())
s = input()
j = 0
for i in s:
	if i == '(':
		j = j + 1
	else:
		j = j - 1
	if j < -1:
		print('No')
		sys.exit()
if j == 0:
	print('Yes')
else:
	print('No')


def is_correct(s):
	cumsum = 0
	for k in s:
		if k == '(':
			cumsum += 1
		elif k == ')':
			cumsum -= 1
		if cumsum == -2:
			return False
	return cumsum == 0
input()
if is_correct(input()):
	print('Yes')
else:
	print('No')


n = int(input())
S = input()
excess = 0
open = 0
for c in S:
	if c == '(':
		open += 1
	elif open == 0:
		excess += 1
	else:
		open -= 1
if open == 0 and excess == 0:
	print('Yes')
elif open == 1 and excess == 1:
	print('Yes')
else:
	print('No')


stack = []
N = int(input())
arr = input()
for j in range(N):
	stack.append(arr[j])
	if len(stack) > 1:
		a = stack.pop()
		b = stack.pop()
		if a == ')' and b == '(':
			continue
		else:
			stack.append(b)
			stack.append(a)
if len(stack) == 0:
	print('Yes')
elif len(stack) == 2 and stack[0] == ')' and (stack[1] == '('):
	print('Yes')
else:
	print('No')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		s = rs()
		ans = 'No'
		if n % 2 == 0:
			depth = 0
			t = 0
			ans = 'Yes'
			for i in range(n):
				if s[i] == '(':
					depth += 1
				else:
					depth -= 1
				if depth < -1:
					ans = 'No'
					break
			if depth > 1:
				ans = 'No'
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


input()
x = 0
for y in input():
	if '(' == y:
		x += 1
	else:
		x -= 1
		if x < -1:
			print('No')
			break
else:
	if x:
		print('No')
	else:
		print('Yes')


List = [' ']
n = int(input())
Read = input()
for i in range(n):
	List.append(Read[i])
Cnto = [0]
Cntc = [0]
for i in range(1, n + 1):
	Cnto.append(0)
	Cntc.append(0)
	Cnto[i] = Cnto[i - 1] + (List[i] == '(')
	Cntc[i] = Cntc[i - 1] + (List[i] == ')')
chk = 0
if Cntc[n] == Cnto[n]:
	chk = 1
id = 1
for i in range(1, n + 1):
	if Cnto[i] < Cntc[i]:
		id = i
		break
List2 = []
if List[id] == '(':
	List2.append('(')
	for i in range(1, n + 1):
		if i != id:
			List2.append(List[i])
else:
	for i in range(1, n + 1):
		if i != id:
			List2.append(List[i])
	List2.append(')')
chk2 = 1
for i in range(1, n + 1):
	Cnto[i] = Cnto[i - 1] + (List2[i - 1] == '(')
	Cntc[i] = Cntc[i - 1] + (List2[i - 1] == ')')
	if Cnto[i] < Cntc[i]:
		chk2 = 0
if chk and chk2:
	print('Yes')
else:
	print('No')


input()
inp = input()
st = []
(fe, se) = (0, 0)
for i in inp:
	if i == '(':
		st.append(0)
	elif i == ')':
		if st:
			st.pop()
		else:
			fe += 1
if st:
	se = len(st)
if fe == se and fe < 2:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
st = []
for i in s:
	if st == []:
		st.append(i)
	elif st[-1] == '(' and i == ')':
		st.pop()
	else:
		st.append(i)
if st == [] or st == [')', '(']:
	print('Yes')
else:
	print('No')


def get_can_be_corrected(seq):
	if len(seq) % 2:
		return 'No'
	cntr = 0
	for b in seq:
		if b == ')':
			cntr -= 1
		else:
			cntr += 1
		if cntr == -2:
			return 'No'
	return 'Yes' if cntr == 0 else 'No'
input()
print(get_can_be_corrected(input()))


n = int(input())
s = str(input())
op = 0
cl = 0
b = 0
for c in s:
	if c == '(':
		op += 1
	if c == ')':
		if op > 0:
			op -= 1
		else:
			b += 1
if b == 1 and op == 1 or (b == 0 and op == 0):
	print('Yes')
else:
	print('No')


input()
k = 0
for ch in input():
	if ch == '(':
		k += 1
	elif k < 0:
		print('No')
		break
	else:
		k -= 1
else:
	print('No' if k else 'Yes')


def Bad_sequence(string):
	ls = []
	for s in string:
		if s == ')':
			if len(ls) == 0:
				ls.append(s)
			elif ls[-1] == ')':
				ls.append(s)
			else:
				ls.pop()
		else:
			ls.append(s)
	if len(ls) == 0 or (len(ls) == 2 and ls[0] == ')' and (ls[1] == '(')):
		print('Yes')
	else:
		print('No')
int_ = input()
brack_string = input()
Bad_sequence(brack_string)


n = int(input())
s = input()
count = 0
fin = False
if s == '':
	print('Yes')
	exit()
elif n % 2 != 0:
	print('No')
	exit()
elif s[0] == ')' and s[1] == ')':
	print('No')
	exit()
else:
	for i in range(len(s)):
		if s[i] == '(':
			count += 1
		elif s[i] == ')':
			if count == 0:
				if s[i + 1] == ')':
					print('No')
					fin = True
					exit()
					break
			count -= 1
	if count == 0 and (not fin):
		print('Yes')
		exit()
	else:
		print('No')
		exit()


def mm(s):
	if s.count('(') != s.count(')'):
		return False
	t = []
	for i in range(len(s)):
		if t == []:
			t += s[i]
		elif t[-1] == '(' and s[i] == ')':
			t.pop()
		else:
			t += s[i]
	if t == [] or t == [')', '(']:
		return True
	return False
n = int(input())
s = input()
if n == 2:
	if s == '()' or s == ')(':
		print('Yes')
	else:
		print('No')
	exit(0)
if n & 1:
	print('No')
	exit(0)
if mm(s):
	print('Yes')
else:
	print('No')


import math
n = int(input())
s = input()
cl = 0
cr = 0
if len(s) % 2 == 1:
	print('No')
else:
	br = False
	for i in range(len(s)):
		if s[i] == '(':
			cl += 1
		else:
			cr += 1
		if cr - cl > 1:
			print('No')
			br = True
			break
	if not br:
		if abs(cl - cr) < 2:
			print('Yes')
		else:
			print('No')


import sys
import math
input = sys.stdin.readline
n = int(input())
s = list(input())
if s.count('(') == s.count(')'):
	op = 0
	cl = 0
	flag = True
	for i in range(n):
		if s[i] == '(':
			op += 1
		else:
			cl += 1
		if cl - op >= 2:
			print('No')
			flag = False
			break
	if flag:
		print('Yes')
else:
	print('No')


def run():
	n = eval(input())
	st = input()
	if n % 2 == 1:
		print('No')
		return
	stack = []
	for i in range(n):
		stack.append(st[i])
		if len(stack) >= 2:
			if stack[-1] == ')' and stack[-2] == '(':
				stack.pop()
				stack.pop()
	if len(stack) == 0 or ''.join(stack) == ')(':
		print('Yes')
	else:
		print('No')
run()


n = int(input())
s = input()
(diff, ci) = ([], 0)
if s.count('(') != s.count(')'):
	print('No')
	exit()
for i in s:
	if i == '(':
		ci += 1
	else:
		ci -= 1
	diff.append(ci)
if min(diff) >= -1:
	print('Yes')
else:
	print('No')


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	(_int, _range, _min, _max) = (int, range, min, max)
	n = int(input())
	arr = [1 if i == '(' else -1 for i in input()]
	if sum(arr) != 0:
		print('No')
	else:
		s = [0] * n
		for i in range(n):
			if i == 0:
				s[i] = arr[i]
			else:
				s[i] = arr[i] + s[i - 1]
				if s[i] == -2:
					print('No')
					break
		else:
			print('Yes')
solution()


from itertools import accumulate
n = int(input())
a = list(accumulate([1 if c == '(' else -1 for c in input()]))
print('No' if min(a) < -1 or a[-1] != 0 else 'Yes')


n = int(input())
(res, k) = (0, 0)
for (i, x) in enumerate(input()):
	if x == '(':
		res += 1
	else:
		res -= 1
	if res < -1:
		k = 1
		break
if k == 0:
	if res == 0:
		print('Yes')
	else:
		print('No')
else:
	print('No')


input()
s = input()
ans = 1
cnt = 0
cha = 0
for x in s:
	if x == '(':
		cnt += 1
	else:
		cnt -= 1
	if cnt < 0:
		if cha == 0:
			cha = 1
			cnt += 1
		else:
			ans = 0
cnt -= cha
if cnt != 0:
	ans = 0
print('Yes' if ans else 'No')


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s)

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

def main():
	n = inp()
	s = insr()
	ans = 0
	for i in s:
		if i == '(':
			ans += 1
		elif i == ')':
			ans -= 1
		if ans < -1:
			print('No')
			break
	else:
		if ans == 0:
			print('Yes')
		else:
			print('No')
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')
main()


n = int(input())
s = input()
if n % 2 == 1:
	print('No')
elif s.count('(') != s.count(')'):
	print('No')
else:
	count = 0
	flag = True
	for i in range(len(s)):
		if s[i] == '(':
			count += 1
		else:
			count -= 1
		if count < -1:
			flag = False
			break
	if flag:
		print('Yes')
	else:
		print('No')


n = int(input())
s = list(input())
l = []
flag = 0
for i in range(0, len(s)):
	if len(l) == 0:
		l.append(s[i])
	elif l[-1] == '(' and s[i] == ')':
		l.pop()
	else:
		l.append(s[i])
if len(l) == 2:
	if l[0] != l[1]:
		print('Yes')
	else:
		print('No')
elif len(l) == 0:
	print('Yes')
else:
	print('No')


def solve(string):
	stack = []
	errors = 0
	for c in string:
		if c == '(':
			stack.append('(')
			continue
		try:
			del stack[-1]
		except IndexError:
			errors += 1
	if errors <= 1 and len(stack) == errors:
		print('Yes')
		return
	print('No')
n = int(input())
sequence = input()
solve(sequence)


N = int(input())
S = list(input())
lnum = len([x for x in S if x == '('])
rnum = len([x for x in S if x == ')'])
if lnum != rnum:
	print('No')
	exit()
lcnt = 0
rcnt = 0
for x in S:
	if x == '(':
		lcnt += 1
	elif lcnt > 0:
		lcnt -= 1
	else:
		rcnt += 1
if rcnt > 1:
	print('No')
else:
	print('Yes')


n = int(input())
a = input()
bh = 0
for i in a:
	if i == '(':
		bh = bh + 1
	else:
		bh = bh - 1
		if bh < -1:
			break
if bh == 0:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
l = 0
a = 0
b = 0
count = 0
flag = True
if n % 2 != 0:
	print('No')
else:
	for i in s:
		if count >= 2:
			flag = False
			break
		if i == '(':
			l += 1
			a += 1
		elif l > 0:
			l -= 1
			b += 1
		else:
			count += 1
			b += 1
	if count <= 1 and a == b and flag:
		print('Yes')
	else:
		print('No')


n = int(input())
s = input()
l = 0
r = 0
dif = [0 for i in range(n)]
ans = 'No'
neg = 0
for i in range(n):
	if s[i] == '(':
		l += 1
		if i != 0:
			dif[i] = dif[i - 1] + 1
		else:
			dif[i] = 1
		if dif[i] < 0:
			neg += 1
	else:
		r += 1
		if i != 0:
			dif[i] = dif[i - 1] - 1
		else:
			dif[0] = -1
		if dif[i] < 0:
			neg += 1
if abs(l - r) != 0 or n % 2 != 0:
	print('No')
elif neg == 2 and min(dif) == -1:
	print('Yes')
elif min(dif) < -1:
	print('No')
else:
	print('Yes')


n = int(input())
s = input()
t = 0
if n % 2:
	print('No')
	exit()
else:
	for c in s:
		if c == '(':
			t += 1
		else:
			t -= 1
		if t < -1:
			print('No')
			exit()
print('Yes' if t == 0 else 'No')


from collections import deque
s = deque()
input()
n = input()

def do(s, n):
	flag = False
	for b in n:
		if b == '(':
			s.append(b)
		elif len(s) <= 0:
			if not flag:
				flag = True
			else:
				return False
		else:
			s.pop()
	if len(s) == 1 and flag or (len(s) == 0 and (not flag)):
		return True
	return False
if do(s, n):
	print('Yes')
else:
	print('No')


from sys import *
from math import *
from collections import Counter
fi = lambda : stdin.readline()
n = int(fi())
s = fi().strip('\n')
if s.count('(') != s.count(')'):
	print('No')
else:
	a = 0
	b = 0
	for i in range(n):
		if a == 0 and s[i] == ')':
			b += 1
		elif s[i] == '(':
			a += 1
		elif s[i] == ')':
			a -= 1
	if a + b == 2 or (a == 0 and b == 0):
		print('Yes')
	else:
		print('No')


import sys
n = int(input())
s = str(input())
if n % 2 == 1:
	print('No')
	sys.exit()
k = 0
(g, gg) = (0, 0)
for i in range(n):
	if s[i] == '(':
		k += 1
		g += 1
	else:
		k -= 1
		gg += 1
	if k <= -2:
		print('No')
		sys.exit()
if g != gg:
	print('No')
	sys.exit()
elif k <= 2:
	print('Yes')
else:
	print('No')


import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans
mod = int(1000000000.0) + 7

def ssinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def nninp():
	return map(int, sys.stdin.readline().strip().split())

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

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
from collections import OrderedDict
n = iinp()
s = ssinp()
if n % 2 == 1:
	print('No')
else:
	left = right = tot = 0
	f = 0
	for c in s:
		if right - left == 2:
			print('No')
			f = 1
			break
		elif c == '(':
			left += 1
		elif left > 0:
			tot += 1
			left -= 1
		else:
			right += 1
	if f == 0:
		if left == 1 and right == 1:
			print('Yes')
		elif left == 0 and right == 0:
			print('Yes')
		else:
			print('No')


n = int(input())
s = input()
if n % 2 == 0:
	k = '('
	k = k + s + ')'
	d = []
	xx = 0
	for i in range(len(k)):
		if k[i] == '(':
			d.append('(')
		elif len(d) != 0:
			d.pop()
		else:
			xx = 1
			print('No')
			break
	if xx == 0:
		if len(d) == 0:
			print('Yes')
		else:
			print('No')
else:
	print('No')


n = int(input())
s = input()
o = 0
for i in s:
	if i == '(':
		o += 1
	else:
		o -= 1
		if o < -1:
			break
if o == 0:
	print('Yes')
else:
	print('No')


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
arr = []
s = input()
for i in s:
	if not arr:
		arr.append(i)
		continue
	if i == '(' and arr[-1] == '(':
		arr.append(i)
	elif i == '(' and arr[-1] == ')':
		arr.append(i)
	elif i == ')' and arr[-1] == '(':
		arr.pop()
	elif i == ')' and arr[-1] == ')':
		print('No')
		exit()
if len(arr) == 2 and arr[0] == ')' and (arr[1] == '(') or len(arr) == 0:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
a = 0
b = 0
if n % 2 == 1:
	print('No')
else:
	for i in s:
		if i == '(':
			a += 1
		if i == ')':
			a -= 1
		if a == -2:
			b = 10
			break
	if a == 0:
		if b == 10:
			print('No')
		else:
			print('Yes')
	else:
		print('No')


n = int(input())
s = input()
L = []
c1 = 0
c2 = 0
for i in range(0, len(s)):
	L.append(s[i])
	if s[i] == '(':
		c1 += 1
	else:
		c2 += 1
flag = 0
if L[0] == ')':
	L = L[1:]
	L.append(')')
	flag = 1
elif L[-1] == '(':
	L = ['('] + L
	L = L[:len(L) - 1]
	flag = 1
temp = 0
stk = []
for i in range(0, len(L)):
	if len(stk) == 0:
		if L[i] == ')':
			flag += 1
			temp = 1
		else:
			stk.append(L[i])
	elif stk[-1] == '(' and L[i] == ')':
		stk.pop()
	else:
		stk.append(L[i])
if temp == 1 and stk == ['(']:
	stk.pop()
if len(stk) == 0 and c1 == c2 and (n % 2 == 0) and (flag < 2):
	print('Yes')
else:
	print('No')


t = int(input())
n = input()
a = []
for i in range(0, len(n)):
	if n[i] == '(':
		a.append('(')
	if n[i] == ')':
		if len(a) == 0:
			a.append(')')
		elif a[len(a) - 1] == '(':
			a.pop(len(a) - 1)
		else:
			a.append(')')
if len(a) == 0:
	print('Yes')
else:
	p = a.count('(')
	q = a.count(')')
	if p == 1 and q == 1:
		print('Yes')
	else:
		print('No')


def countbrackets(string):
	if string.replace('(', '').replace(')', ''):
		return None
	string = [x == '(' for x in string]
	(bopen, extraclose) = (0, 0)
	for x in string:
		if x:
			bopen += 1
		elif bopen == 0:
			extraclose += 1
		else:
			bopen -= 1
	return (bopen, extraclose)
input()
bstring = input()
ans = countbrackets(bstring)
if ans == (1, 1) or ans == (0, 0):
	print('Yes')
else:
	print('No')


(_, string) = (input(), input())
stack = []
errors = 0
for i in range(len(string)):
	if string[i] is ')':
		if len(stack) > 0:
			stack.pop()
		else:
			errors += 1
	else:
		stack.append(1)
if errors == 1 and len(stack) == 1 or (errors == 0 and len(stack) == 0):
	print('Yes')
else:
	print('No')


from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

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

def LS():
	return [list(x) for x in sys.stdin.readline().split()]

def S():
	res = list(sys.stdin.readline())
	if res[-1] == '\n':
		return res[:-1]
	return res

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007

def A():
	(n, d, e) = IR(3)
	e *= 5
	ans = n
	m = n // e
	for i in range(m + 1):
		ans = min(ans, n - d * (n // d))
		n -= e
	print(ans)
	return

def B():
	(b, g, n) = IR(3)
	(b, g) = (min(b, g), max(b, g))
	if n <= b:
		print(n + 1)
	elif n <= g:
		print(b + 1)
	else:
		print(abs(n - b - g) + 1)
	return

def C():
	n = I()
	s = S()
	if n % 2:
		print('No')
		return
	q = deque()
	for i in s:
		if i == ')':
			if q and q[-1] == '(':
				q.pop()
			else:
				q.append(i)
		else:
			q.append(i)
	if len(q) == 2:
		if q[0] != q[1]:
			print('Yes')
		else:
			print('No')
	elif not q:
		print('Yes')
	else:
		print('No')
	return

def D():
	return

def E():
	return

def F():
	return

def G():
	return

def H():
	return
C()


n = int(input())
string = input().strip()
if string.count(')') == n / 2 and string.count(')') == n / 2:
	alist = []
	for i in string:
		if i == '(':
			alist.append(i)
		elif len(alist) == 0:
			alist.append(i)
		elif alist[-1] == '(':
			alist.pop()
		else:
			alist.append(i)
	gstring = ''.join(alist)
	if len(gstring) == 0:
		print('Yes')
	else:
		count = 0
		for i in range(len(gstring) // 2):
			if gstring[i] == '(' and gstring[n - i - 1] == ')':
				pass
			else:
				count += 1
		if count > 1:
			print('No')
		else:
			print('Yes')
else:
	print('No')


len = int(input())
s = input()
st = neg = 0
for i in s:
	if i == '(':
		st += 1
	else:
		st -= 1
	neg = min(neg, st)
if st != 0 or neg < -1:
	print('No')
else:
	print('Yes')


n = int(input())
sk = input()
st = 0
if n % 2 == 1:
	print('No')
else:
	k = 0
	for el in sk:
		if el == ')':
			st += 1
		elif el == '(':
			st -= 1
		if st >= 2:
			print('No')
			k = 1
			break
	if k == 0:
		if abs(st) > 1:
			print('No')
		else:
			print('Yes')


I0 = lambda : map(int, input().split())
I1 = lambda : int(input())
I2 = lambda : list(map(int, input().split()))
n = I1()
s = input()
stack = list()
t = 0
f = False
res = 'Yes'
for i in range(n):
	if s[i] == '(':
		stack.append(1)
		t += 1
	elif t == 0:
		if f == False:
			f = True
		else:
			res = 'No'
			break
	else:
		stack.pop()
		t -= 1
if res == 'Yes':
	if f == False and t == 0:
		print(res)
	elif f == False and t != 0:
		print('No')
	elif f == True and t == 0:
		print('No')
	elif f == True and t == 1:
		print(res)
	else:
		print('No')
else:
	print(res)


n = int(input())
string = input()
counter = 0
k = 1
for i in string:
	if i == '(':
		counter += 1
	else:
		counter -= 1
	if counter < -1:
		k = 0
		break
if counter == 0:
	print('Yes')
elif k == 0:
	print('No')
else:
	print('No')


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

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

def li():
	return list(mi())
n = ii()
s = si()
c = 0
for i in s:
	if i == '(':
		c += 1
	else:
		c -= 1
	if c <= -2:
		print('No')
		exit()
if c == 0:
	print('Yes')
else:
	print('No')


n = int(input())
a = [str(i) for i in input()]
b = []
x = 0
if n % 2 != 0:
	print('No')
	exit(0)
for i in range(0, n):
	if a[i] == '(':
		b.append('(')
	if a[i] == ')':
		if len(b) > 0:
			b.pop()
		else:
			x += 1
if x > 1 or len(b) > 1:
	print('No')
else:
	print('Yes')


def solve():
	n = int(input())
	s = input()
	op = 0
	cl = 0
	stack = []
	for i in s:
		op += int(i == '(')
		cl += int(i == ')')
		if len(stack) == 0:
			stack.append(i)
		elif stack[-1] == '(' and i == ')':
			stack.pop()
		else:
			stack.append(i)
	if len(stack) <= 2 and op == cl:
		print('Yes')
		return
	print('No')
solve()


from collections import Counter
n = int(input())
S = input()
D = Counter(S)
if ')' in D and '(' in D:
	if D['('] == D[')']:
		c = 0
		x = float('inf')
		y = float('-inf')
		for _ in S:
			if _ == '(':
				c += 1
			else:
				c -= 1
			x = min(x, c)
			y = max(x, c)
		if abs(x) < 2 and abs(y) < 2:
			print('Yes')
		else:
			print('No')
	else:
		print('No')
else:
	print('No')


n = int(input())
s = input()
if s.count('(') != s.count(')'):
	print('No')
	exit(0)
d = 0
for c in s:
	if c == '(':
		d += 1
	else:
		d -= 1
	if d <= -2:
		print('No')
		exit(0)
print('Yes')


n = int(input())
s = input()
lc = 0
rc = 0
l = 0
r = 0
ch = 1
for i in range(len(s)):
	if s[i] == ')':
		l += 1
		lc += 1
	else:
		r += 1
		rc += 1
	if l - r >= 2:
		ch = 0
if ch == 1 and lc == rc:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(input())
temp = []
for i in range(n):
	if i == 0:
		temp.append(a[i])
	elif len(temp) == 0:
		temp.append(a[i])
	elif a[i] == ')':
		if temp[-1] == '(':
			temp.pop()
		else:
			temp.append(a[i])
	else:
		temp.append(a[i])
if len(temp) == 2 and len(set(temp)) == 2 or len(temp) == 0:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
z = 0
m = 0
for x in s:
	z += 2 * (x == '(') - 1
	m = min(m, z)
if z == 0 and m > -2:
	print('Yes')
else:
	print('No')


n = int(input(''))
s = str(input(''))
if n % 2 == 1:
	print('No')
	exit(0)
flag = False
stack = []
for c in s:
	if c == ')':
		if len(stack) == 0:
			if flag:
				print('No')
				exit(0)
			else:
				flag = True
		else:
			stack.pop()
	else:
		stack.append(c)
if len(stack) == 0 or (len(stack) == 1 and flag):
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
o = s.count('(')
c = s.count(')')
count = 0
pairs = 0
for b in s:
	if b == '(':
		count += 1
	elif count:
		count -= 1
		pairs += 1
if n % 2 or o != c:
	print('No')
elif pairs >= -1 + n // 2:
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline
from math import ceil
n = int(input())
l = input().strip()
left = 0
right = 0
state = 0
for x in l:
	if x == '(':
		left += 1
		state += 1
	else:
		right += 1
		state -= 1
	if state <= -2:
		print('No')
		exit(0)
if left == right:
	print('Yes')
else:
	print('No')


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n = int(input())
s = input()
z = deque([])
for i in s:
	if i == '(':
		z.append(i)
	elif i == ')':
		if z:
			if z[-1] == '(':
				z.pop()
			else:
				print('No')
				exit()
		else:
			z.append(i)
if len(z) == 0 or list(z) == [')', '(']:
	print('Yes')
else:
	print('No')


import sys
input = lambda : sys.stdin.readline().strip()
n = int(input())
s = input()
stack = []
for i in s:
	if i == '(':
		stack.append('(')
	elif i == ')':
		if len(stack) > 0 and '(' == stack[len(stack) - 1]:
			stack.pop()
		else:
			stack.append(')')
if stack == [')', '('] or stack == []:
	print('Yes')
else:
	print('No')


def check(s, n):
	c = 0
	for i in s:
		if i == '(':
			c += 1
		else:
			c -= 1
		if c < -1:
			break
	print('No' if c else 'Yes')
n = int(input())
s = input()
check(s, n)


import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
c1 = 0
c2 = 0
for i in range(n):
	if s[i] == '(':
		c1 += 1
	else:
		c2 += 1
if c1 == c2:
	op = 0
	for i in range(n):
		if op < -1:
			break
		if s[i] == '(':
			op += 1
		else:
			op -= 1
	if op > 0 or op < 0:
		print('No')
	else:
		print('Yes')
else:
	print('No')


def process():
	n = int(input())
	s = input()
	if n % 2 == 1:
		print('No')
		return
	cnt = 0
	min_cnt = 1000000000000
	for i in range(n):
		if s[i] == '(':
			cnt += 1
		else:
			cnt -= 1
		min_cnt = min(cnt, min_cnt)
	if cnt != 0:
		print('No')
		return
	print(min_cnt >= -1 and 'Yes' or 'No')
process()


n = int(input())
s = input()
ans = 0
p = 0
a = 0
if n % 2 != 0:
	print('No')
	exit()
for i in s:
	if i == ')':
		if p > 0:
			p -= 1
		else:
			a += 1
	else:
		p += 1
if p == a and p < 2:
	print('Yes')
else:
	print('No')


n = int(input())
l1 = input()
k = 0
ans = ''
for i in l1:
	if i == '(':
		k += 1
	else:
		k -= 1
	if k == -2:
		ans = 'No'
		break
if k == 0:
	ans = 'Yes'
else:
	ans = 'No'
print(ans)


n = int(input())
string = input()
c = 0
flag = False
if n % 2 != 0:
	print('No')
else:
	fake_string = '(' + string + ')'
	temp = []
	for i in range(len(fake_string)):
		if fake_string[i] == '(':
			c += 1
		elif c != 0:
			c -= 1
		else:
			print('No')
			flag = True
			break
	if not flag:
		if c == 0:
			print('Yes')
		else:
			print('No')


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 5
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = list(stdin.readline().strip('\n'))
	st = []
	for i in range(n):
		if len(st) == 0:
			st.append(a[i])
		elif st[-1] == '(' and a[i] == ')':
			st.pop(-1)
		else:
			st.append(a[i])
	if len(st) == 0 or ((st[0] == ')' and st[-1] == '(') and len(st) == 2):
		print('Yes')
	else:
		print('No')


def check(str):
	stack = []
	for ch in str:
		if ch == '(':
			stack.append(ch)
		elif len(stack) > 0 and stack[-1] == '(':
			stack.pop(-1)
		else:
			stack.append(ch)
	if sorted(stack) == sorted(['(', ')']) or stack == []:
		return 'Yes'
	else:
		return 'No'
input()
print(check(input()))


import sys
n = int(input())
k = input()
l = [k[i] for i in range(n)]
char = [-1 if l[i] == ')' else 1 for i in range(n)]
su = [0] * n
su[0] = char[0]
for i in range(1, n):
	su[i] = su[i - 1] + char[i]
if su[-1] != 0:
	print('No')
else:
	for i in range(n):
		j = n - i - 1
		if l[j] == '(':
			l.pop(j)
			l = ['()'] + l
			break
	char = [-1 if l[i] == ')' else 1 for i in range(n)]
	su = [0] * n
	su[0] = char[0]
	for i in range(1, n):
		su[i] = su[i - 1] + char[i]
	for i in su:
		if i < 0:
			print('No')
			sys.exit(0)
	print('Yes')


N = int(input())
S = input()
cnt = 0
min_cnt = 0
for i in range(N):
	if S[i] == '(':
		cnt += 1
	else:
		cnt -= 1
		min_cnt = min(min_cnt, cnt)
if cnt == 0 and min_cnt >= -1:
	print('Yes')
else:
	print('No')


n = int(input())
s = str(input())
an = 0
g = []
vu = False
for i in range(n):
	if s[i] == '(':
		an += 1
	else:
		an -= 1
	if an == -1 and vu == False:
		an = 0
		vu = True
	else:
		g.append(an)
if vu:
	an -= 1
	g.append(an)
if -2 in g or -1 in g or an != 0:
	print('No')
	exit()
print('Yes')


from sys import stdin

def get_ints():
	return list(map(int, stdin.readline().strip().split()))
n = int(input())
s = input()
if n % 2 == 1:
	print('No')
	exit()
baddies = []
offset = 0
for c in s:
	if len(baddies) == 0 and c == ')':
		offset -= 1
		continue
	if c == '(':
		baddies.append(1)
	else:
		baddies.pop()
if s[0] == ')' and len(s[1:]) > 1 and (len(set(s[1:])) == 1):
	print('No')
	exit()
if len(baddies) == 0 and offset == 0 or 1 + offset == 0:
	print('Yes')
else:
	print('No')


n = int(input())
a = input()
cnt1 = 0
cnt2 = 0
flag = 0
for i in range(n):
	if a[i] == '(':
		cnt1 += 1
	else:
		cnt2 += 1
if cnt1 != cnt2:
	print('No')
else:
	for i in range(n):
		if a[i] == '(':
			cnt1 += 1
		else:
			cnt2 += 1
		if cnt2 - cnt1 > 1:
			flag = 1
			break
	if flag:
		print('No')
	else:
		print('Yes')


n = int(input())
s = input()
L = []
for i in s:
	if i == '(':
		L.append(1)
	elif len(L) > 0 and L[-1] == 1:
		L.pop()
	else:
		L.append(-1)
if L == [] or L == [-1, 1]:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if s.count('(') != s.count(')'):
	print('No')
else:
	x = 0
	for i in s:
		if i == '(':
			x += 1
		else:
			x -= 1
		if x <= -2:
			print('No')
			break
	else:
		print('Yes')


n = int(input())
present = input().rstrip()
level = 0
min_level = 0
for ch in present:
	if ch == '(':
		level += 1
	else:
		level -= 1
		min_level = min(min_level, level)
if min_level >= -1 and level == 0:
	print('Yes')
else:
	print('No')


import sys
import collections
n = int(sys.stdin.readline().split()[0])
s = sys.stdin.readline().split()[0]
balance = 0
if n % 2 == 1:
	sys.stdout.write('No')
else:
	for i in range(n):
		if s[i] == '(':
			balance += 1
		else:
			balance -= 1
		if balance == -2:
			sys.stdout.write('No')
			break
	if balance > 0:
		sys.stdout.write('No')
	elif balance == 0:
		sys.stdout.write('Yes')


n = input()
s = input()
n = len(s)
if n % 2:
	print('No')
	exit()
if s.count('(') != n / 2:
	print('No')
	exit()
while s != s.replace('()', ''):
	for i in range(0, 15):
		s = s.replace(2 ** i * '(' + 2 ** i * ')', '')
if len(s) <= 2:
	print('Yes')
else:
	print('No')


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
arr = fast()
c = 0
ans = 0
if n % 2 == 1:
	print('No')
	exit()
for i in arr:
	if i == '(':
		ans += 1
		continue
	ans -= 1
	if ans < -1:
		print('No')
		exit()
if ans == 0:
	print('Yes')
else:
	print('No')


class cinn:

	def __init__(self):
		self.x = []

	def cin(self, t=int):
		if len(self.x) == 0:
			a = input()
			self.x = a.split()
			self.x.reverse()
		return self.get(t)

	def get(self, t):
		return t(self.x.pop())

	def clist(self, n, t=int):
		l = [0] * n
		for i in range(n):
			l[i] = self.cin(t)
		return l

	def clist2(self, n, t1=int, t2=int, t3=int, tn=2):
		l = [0] * n
		for i in range(n):
			if tn == 2:
				a1 = self.cin(t1)
				a2 = self.cin(t2)
				l[i] = (a1, a2)
			elif tn == 3:
				a1 = self.cin(t1)
				a2 = self.cin(t2)
				a3 = self.cin(t3)
				l[i] = (a1, a2, a3)
		return l

	def clist3(self, n, t1=int, t2=int, t3=int):
		return self.clist2(self, n, t1, t2, t3, 3)

	def cout(self, i, ans=''):
		if ans == '':
			print('Case #' + str(i + 1) + ':', end=' ')
		else:
			print('Case #' + str(i + 1) + ':', ans)

	def printf(self, thing):
		print(thing, end='')

	def countlist(self, l, s=0, e=None):
		if e == None:
			e = len(l)
		dic = {}
		for el in range(s, e):
			if l[el] not in dic:
				dic[l[el]] = 1
			else:
				dic[l[el]] += 1
		return dic

	def talk(self, x):
		print(x, flush=True)

	def dp1(self, k):
		L = [-1] * k
		return L

	def dp2(self, k, kk):
		L = [-1] * k
		for i in range(k):
			L[i] = [-1] * kk
		return L

	def isprime(self, n):
		if n == 1 or n == 0:
			return False
		for i in range(2, int(n ** 0.5 + 1)):
			if n % i == 0:
				return False
		return True

	def factors(self, n):
		from functools import reduce
		return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

	def nthprime(self, n):
		i = 0
		s = 2
		L = []
		while i < n:
			while not self.isprime(s):
				s += 1
			L.append(s)
			s += 1
			i += 1
		return L

	def matrixin(self, m, n, t=int):
		L = []
		for i in range(m):
			p = self.clist(n, t)
			L.append(p)
		return L

	def seive(self, k):
		n = k + 1
		L = [True] * n
		L[1] = False
		L[0] = False
		for i in range(2, n):
			if L[i] == True:
				for j in range(2 * i, n, i):
					L[j] = False
		return L

	def seiven(self, n, L):
		i = 0
		for j in range(len(L)):
			if L[j] == True:
				i += 1
			if i == n:
				return j

	def matrixin2(self, m, t=int):
		L = []
		for i in range(m):
			iny = self.cin(str)
			lsmall = []
			for el in iny:
				lsmall.append(t(el))
			L.append(lsmall)
		return L
c = cinn()
n = c.cin()
s = c.cin(str)
g = True
cou = 0
for el in s:
	if el == '(':
		cou += 1
	else:
		cou -= 1
	if cou == -1 and g == True:
		g = False
		cou = 0
	if cou == -1 and g == False:
		break
if cou == 0 and g:
	print('Yes')
elif cou == 1 and (not g):
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
stack = []
move = False
ans = True
for i in s:
	if i == '(':
		stack.append('(')
	elif i == ')':
		if len(stack):
			stack.pop()
		elif not move:
			move = True
		else:
			ans = False
			break
if len(stack) and move:
	stack.pop()
	move = False
print('Yes' if ans and (not len(stack)) and (not move) else 'No')


n = int(input())
s = input()
(a, b, c) = (0, 0, 0)
for c in s:
	if c == '(':
		a += 1
	elif a > 0:
		a -= 1
	else:
		b += 1
if a == 0 and b == 0:
	print('Yes')
elif a == 1 and b == 1:
	print('Yes')
else:
	print('No')


A = ['(', '(', ')']
n = int(input())
A = input()

def check_sequence(A):
	counter = 0
	for i in A:
		if i == '(':
			counter += 1
		else:
			counter -= 1
		if counter < -1:
			return 'No'
	if counter != 0:
		return 'No'
	return 'Yes'
print(check_sequence(A))


n = int(input())
a = list(input())
arr = []
for i in range(n):
	if len(arr) == 0:
		arr.append(a[i])
	else:
		x = arr.pop()
		if x == '(' and a[i] == ')':
			continue
		else:
			arr.append(x)
			arr.append(a[i])
if len(arr) == 0:
	print('Yes')
elif len(arr) == 2 and (arr[0] == '(' and arr[1] == ')' or (arr[0] == ')' and arr[1] == '(')):
	print('Yes')
else:
	print('No')


n = int(input())
if n % 2 == 1:
	print('No')
	exit()
brackets = str(input())
stack = list()
k = 0
closed = 0
opened = 0
for br in brackets:
	if br == '(':
		stack.append(br)
		k += 1
		opened += 1
	else:
		if len(stack):
			stack.pop()
			k -= 1
		closed += 1
if (k == 1 or k == 0) and closed == opened:
	print('Yes')
else:
	print('No')


n = int(input())
arr = list(str(input()))
count = 0
if arr.count('(') != arr.count(')'):
	print('No')
else:
	for i in range(n):
		if arr[i] == '(':
			count += 1
		elif arr[i] == ')':
			count -= 1
		if count == -2:
			print('No')
			break
	else:
		print('Yes')


n = int(input())
s = input().rstrip()
l = []
x = list(s)
A = 0
if n % 2 != 0:
	print('No')
else:
	S = 0
	G = 0
	for i in range(0, len(x)):
		if A >= 2:
			G = -1
			break
		if x[i] == '(':
			l.append(x[i])
		elif x[i] == ')':
			if len(l) != 0:
				del l[0]
			else:
				A += 1
	if G == -1:
		print('No')
	elif A == len(l):
		print('Yes')
	else:
		print('No')


n = int(input())
start = 0
tmp = 0
wrong = 0
for b in input():
	if b == '(':
		start += 1
	elif start > 0:
		start -= 1
	else:
		wrong += 1
if wrong == 1:
	if start == 1:
		print('Yes')
	else:
		print('No')
elif wrong == 0:
	if start == 0:
		print('Yes')
	else:
		print('No')
else:
	print('No')


n = int(input())
s = input()
if n % 2 == 1:
	print('No')
else:
	dp = [0] * (n + 1)
	flag = 0
	for i in range(1, n + 1):
		if s[i - 1] == '(':
			dp[i] = dp[i - 1] + 1
		else:
			dp[i] = dp[i - 1] - 1
		if dp[i] < -1:
			flag = 1
			print('No')
			break
	if flag == 0:
		if dp[n] != 0:
			print('No')
		else:
			print('Yes')


input()
s = input()
ct1 = 0
ct2 = 0
for i in s:
	if i == '(':
		ct1 += 1
	else:
		ct1 -= 1
	ct2 = min(ct2, ct1)
if ct1 == 0 and ct2 >= -1:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
i = s.find(')')
if i == -1:
	print('No')
	exit()
s = s[:i] + s[i + 1:] + ')'
count = 0
for c in s:
	if c == '(':
		count += 1
	else:
		count -= 1
		if count < 0:
			print('No')
			exit()
if count == 0:
	print('Yes')
else:
	print('No')


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

def possible(n, s):
	lc = 0
	rc = 0
	for e in s:
		if e is '(':
			lc += 1
		else:
			rc += 1
		if rc - lc >= 2:
			return False
	return lc == rc
r = possible(n, s)
print('Yes' if r else 'No')


input()
s = input()
cnt = 0
ans = 'Yes'
for item in s:
	if item == '(':
		cnt += 1
	else:
		cnt -= 1
	if cnt <= -2:
		ans = 'No'
		break
if ans == 'Yes':
	if cnt:
		ans = 'No'
print(ans)


n = int(input())
s = input()
ans = s.count('(') == s.count(')')
if ans:
	b = 0
	was = False
	for i in s:
		if i == '(':
			b += 1
		else:
			b -= 1
		if b == -1:
			if was:
				ans = False
				break
			was = True
			b = 0
print('Yes' if ans else 'No')


cts = [0, 0]
n = int(input())
seq = list(input())
tick = 0
tf = 0
mt = 0
for i in range(0, len(seq)):
	if seq[i] == '(':
		cts[0] += 1
		tick += 1
	else:
		cts[1] += 1
		tick -= 1
	mt = min(mt, tick)
if cts[0] == cts[1] and mt >= -1:
	print('Yes')
else:
	print('No')


n = int(input())
str = input()
cnt = 0
m = cnt
for i in range(len(str)):
	if str[i] == '(':
		cnt += 1
	else:
		cnt -= 1
		m = min(cnt, m)
if m >= -1 and cnt == 0:
	print('Yes')
else:
	print('No')


n = int(input())
bracket = input().strip()
if bracket.count('(') != bracket.count(')'):
	print('No')
else:
	(l_bracket, r_bracket) = (0, 0)
	temp = 1
	for i in bracket:
		if i == '(':
			l_bracket += 1
		if i == ')':
			r_bracket += 1
		if r_bracket - l_bracket > 1:
			temp = 0
			break
	if temp == 1:
		print('Yes')
	else:
		print('No')


def solve(n, seq):
	incorrect = 0
	currentOpen = 0
	index = 0
	while index < n:
		if index == 0:
			if seq[index] == ')':
				incorrect += 1
			else:
				currentOpen += 1
		elif seq[index] == '(':
			currentOpen += 1
		elif currentOpen < 1:
			incorrect += 1
		else:
			currentOpen -= 1
		index += 1
	if incorrect <= 1 and incorrect == currentOpen:
		return 'Yes'
	else:
		return 'No'
n = int(input())
seq = list(input())
print(solve(n, seq))


def func(A):
	if len(A) % 2 != 0:
		print('No')
		return
	stack = []
	for i in A:
		if i == '(':
			stack.append(i)
		elif stack and stack[-1] == '(':
			stack.pop()
		else:
			stack.append(i)
	if len(stack) == 0:
		print('Yes')
		return
	if len(stack) == 2 and stack[0] == ')' and (stack[1] == '('):
		print('Yes')
		return
	print('No')
_ = input()
func(input())


n = int(input())
s = input()
(a, b) = (0, 0)
for x in s:
	if x == ')':
		if b > 0:
			b -= 1
		else:
			a += 1
	else:
		b += 1
if a == b == 0 or a == b == 1:
	print('Yes')
else:
	print('No')


t = int(input())
ss = input()
(op, out) = (0, 0)
for i in range(0, len(ss)):
	if ss[i] == '(':
		op += 1
	elif op > 0:
		op -= 1
	else:
		out += 1
if op == 0 and out == 0:
	print('Yes')
elif op == 1 and out == 1:
	print('Yes')
else:
	print('No')


size = int(input())
sequence = input()
counter = 0
possible = True
for l in sequence:
	if l == ')':
		counter -= 1
	elif l == '(':
		counter += 1
	if counter < -1:
		possible = False
		break
if counter != 0:
	possible = False
if possible:
	print('Yes')
else:
	print('No')


n = int(input())
a = input()
s = 0
v = 0
f = False
for i in range(n):
	if a[i] == '(':
		s += 1
	if a[i] == ')':
		s -= 1
		if s < -1:
			v += 2
			break
if s != 0:
	print('No')
elif v > 1:
	print('No')
else:
	print('Yes')


n = int(input())
stck = []
temp = input()
lst = [a for a in temp]
stck.append(lst[0])
for i in range(1, n):
	temp = lst[i]
	if len(stck) != 0 and temp == ')' and (stck[-1] == '('):
		stck.pop()
	else:
		stck.append(temp)
res = 'No'
if len(stck) == 0:
	res = 'Yes'
elif len(stck) == 2:
	if stck[0] == ')' and stck[1] == '(':
		res = 'Yes'
print(res)


n = int(input())
seq = list(input())
stack = 0
minstack = 0
for i in seq:
	if i == '(':
		stack += 1
	else:
		stack -= 1
	if stack < minstack:
		minstack = stack
if stack == 0 and minstack >= -1:
	print('Yes')
else:
	print('No')


def solvea():
	n = int(input())
	d = int(input())
	e = 5 * int(input())
	best = 0
	for enr in range(n // e + 1):
		curr = e * enr
		curr += d * ((n - curr) // d)
		if curr <= n and curr > best:
			best = curr
	print(n - best)

def solveb():
	a = int(input())
	b = int(input())
	n = int(input())
	ans = 0
	for i in range(a + 1):
		for j in range(b + 1):
			if i + j == n:
				ans += 1
	print(ans)

def solvec():
	n = int(input())
	curr_bal = 0
	min_bal = 0
	for e in input():
		if e == '(':
			curr_bal += 1
		else:
			curr_bal -= 1
		if curr_bal < min_bal:
			min_bal = curr_bal
	if min_bal >= -1 and curr_bal == 0:
		print('Yes')
	else:
		print('No')

def __starting_point():
	solvec()
__starting_point()


import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.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 = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.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:
			self.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 get_int():
	return int(input())

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

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

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

def get_strs():
	return get_str().split(' ')

def flat_list(arr):
	return [item for subarr in arr for item in subarr]

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def binary_search(good, left, right, delta=1, right_true=False):
	limits = [left, right]
	while limits[1] - limits[0] > delta:
		if delta == 1:
			mid = sum(limits) // 2
		else:
			mid = sum(limits) / 2
		if good(mid):
			limits[int(right_true)] = mid
		else:
			limits[int(~right_true)] = mid
	if good(limits[int(right_true)]):
		return limits[int(right_true)]
	else:
		return False

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def solve_a():
	n = get_int()
	d = get_int()
	e = get_int()
	best = float('inf')
	while n >= 0:
		best = min(best, n % d)
		n -= 5 * e
	return best

def solve_b():
	b = get_int()
	g = get_int()
	n = get_int()
	return min(b, n) - max(0, n - g) + 1

def solve_c():
	n = get_int()
	s = get_str()
	open = 0
	for (idx, char) in enumerate(s):
		if char == '(':
			open += 1
		else:
			open -= 1
		if open < -1:
			return False
	return open == 0
print(yes_no(solve_c()).title())


n = int(input())
s = input()
d = {'(': 0, ')': 0}
maxm = 0
for i in range(n):
	if s[i] == '(':
		d['('] += 1
	else:
		d[')'] += 1
	maxm = max(maxm, d[')'] - d['('])
if d['('] != d[')'] or maxm > 1:
	print('No')
else:
	print('Yes')


N = int(input())
s = input()
suma = 0
maz = 0
for i in s:
	suma += 1 if i == '(' else -1
	maz = min(maz, suma)
print('Yes' if maz >= -1 and suma == 0 else 'No')


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
from math import gcd
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
n = inp(1)
s = input().strip()
stack = []
for c in s:
	if len(stack) != 0 and c == ')':
		if stack[-1] == ')':
			stack.append(c)
		else:
			stack.pop(-1)
	else:
		stack.append(c)
stack.sort()
if len(stack) == 0 or stack == ['(', ')']:
	print('Yes')
else:
	print('No')


n = int(input())
seq = input()
counter = 0
for c in seq:
	if c == '(':
		counter += 1
	else:
		counter -= 1
	if counter < -1:
		break
if counter == 0:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if n % 2:
	print('No')
else:
	fault = 0
	score = 0
	for i in s:
		if i == '(':
			score += 1
		elif score > 0:
			score -= 1
		else:
			fault += 1
			if fault > 1:
				print('No')
				break
	if fault < 2:
		if score != fault:
			print('No')
		else:
			print('Yes')


n = int(input())
s = input()
diff = 0
min_diff = 0
for i in range(n):
	if s[i] == '(':
		diff += 1
	else:
		diff -= 1
		min_diff = min([min_diff, diff])
if min_diff >= -1 and diff == 0:
	print('Yes')
else:
	print('No')


cnt = 0
n = int(input())
s = input()
f = 0
for i in s:
	if i == '(':
		cnt += 1
	else:
		cnt -= 1
	if cnt == -2:
		f = 1
		break
if f == 0 and cnt == 0:
	print('Yes')
else:
	print('No')


n = int(input())
string_val = input()
flag = 0
arr = []
for x in string_val:
	if x == '(':
		arr.append(1)
	else:
		arr.append(-1)
if sum(arr) != 0:
	flag = 0
else:
	sum = 0
	for y in arr:
		if sum == -2:
			flag = 0
			break
		else:
			flag = 1
			sum = sum + y
if flag == 1:
	print('Yes')
else:
	print('No')


def checker(n, string):
	count = 0
	for i in string:
		if i == ')':
			count -= 1
		else:
			count += 1
	if count == 0:
		return True
	else:
		return False

def solver(n, string):
	if n % 2 != 0:
		return 'No'
	elif n != len(string):
		return 'No'
	else:
		count = 0
		for i in string:
			if i == ')':
				count -= 1
			else:
				count += 1
			if count < -1:
				return 'No'
	return 'Yes'
n = int(input())
string = input()
if checker(n, string):
	print(solver(n, string))
else:
	print('No')


n = int(input())
s = input()
if s.count('(') != s.count(')'):
	exit(print('No'))
st = []
ct = 0
for i in range(n):
	if s[i] == '(':
		st.append(s[i])
	if s[i] == ')':
		if len(st) != 0:
			st.pop()
		else:
			ct += 1
if ct > 1:
	print('No')
else:
	print('Yes')


stack = []
input()
seq = input()
for br in seq:
	if br == '(':
		stack.append(br)
	elif br == ')':
		if stack and stack[-1] == '(':
			stack.pop()
		else:
			stack.append(br)
if not stack:
	print('Yes')
elif len(stack) == 2 and '(' in stack and (')' in stack):
	print('Yes')
else:
	print('No')


n = int(input())
expr = input()
first = expr.count('(')
if first == n - first:
	stack = []
	stack2 = []
	for val in expr:
		if val == '(':
			stack.append('(')
		elif stack:
			stack.pop(0)
		else:
			stack2.append(')')
	if len(stack) < 2 and len(stack2) < 2:
		print('Yes')
	else:
		print('No')
else:
	print('No')


n = int(input())
s = input()
c = 0
ck = 1
for i in s:
	if i == '(':
		c += 1
	else:
		c -= 1
	if c < -1:
		ck = 0
		break
if ck == 0:
	print('No')
elif c == 0:
	print('Yes')
else:
	print('No')


def main():
	n = int(input())
	s = input()
	left = 0
	right = 0
	for i in s:
		if i == '(':
			left += 1
		elif left > 0:
			left -= 1
		else:
			right += 1
	if left == right and left <= 1:
		print('Yes')
		return
	print('No')
main()


from sys import exit
n = int(input())
s = input()
cur = 0
for ch in s:
	if ch == '(':
		cur += 1
	else:
		cur -= 1
	if cur == -2:
		print('No')
		exit(0)
print('Yes' if cur == 0 else 'No')


n = int(input())
seq = input()
(cnt1, cnt2) = (0, 0)
for i in seq:
	if i == '(':
		cnt1 += 1
	else:
		cnt1 -= 1
	cnt2 = min(cnt1, cnt2)
if cnt1 == 0 and cnt2 >= -1:
	print('Yes')
else:
	print('No')


n = int(input())
x = input()
c = 0
cmin = 0
for i in range(n):
	if x[i] == '(':
		c += 1
	else:
		c -= 1
	if c == -2:
		cmin += 1
if c != 0 or cmin > 0:
	print('No')
else:
	print('Yes')


a = int(input())
(_0, _1) = (0, 0)
for i in input():
	if i == '(':
		_0 += 1
	elif _0:
		_0 -= 1
	else:
		_1 += 1
if _1 == _0 == 1 or _1 == _0 == 0:
	print('Yes')
else:
	print('No')


ii = lambda : int(input())
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
stack = [1]
_ = ii()
for i in input():
	if i == '(':
		stack.append(1)
	else:
		if not stack:
			print('No')
			exit()
		stack.pop()
print('No' if len(stack) != 1 else 'Yes')


from sys import stdin, stdout
n = int(stdin.readline().strip())
s = stdin.readline().strip()
ctr = 0
flag = False
for i in s:
	if i == '(':
		ctr += 1
	else:
		ctr -= 1
		if ctr < -1:
			flag = True
			break
if ctr != 0 or flag:
	stdout.write('No')
else:
	stdout.write('Yes')


n = int(input())
s = input()
if n % 2 == 1:
	print('No')
	exit()
op = 0
cl = 0
for i in s:
	if i == '(':
		op += 1
	elif op > 0:
		op -= 1
	elif cl < 1:
		cl += 1
	else:
		print('No')
		exit()
op -= cl
print('Yes' if op == 0 else 'No')


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
n = ini()
s = ins()
if n % 2 != 0:
	print('No')
else:
	count = 0
	ans = True
	for i in s:
		count += 1 if i == '(' else -1
		if count <= -2:
			ans = False
			break
	if count != 0:
		ans = False
	print('Yes' if ans else 'No')


(a, b, c) = (input(), 0, 0)
a = input()
for x in a:
	if x == '(':
		b += 1
	else:
		b -= 1
		c = min(c, b)
if b == 0 and c >= -1:
	print('Yes')
else:
	print('No')


import sys
n = int(input())
b = list(sys.stdin.readline().rstrip())
stk = list()
target = -1
for i in range(n):
	if b[i] == '(':
		stk.append('(')
	else:
		if len(stk) == 0:
			target = i
			break
		stk.pop()
if target == -1 and len(stk) != 0:
	print('No')
	exit(0)
if target == -1:
	print('Yes')
	exit(0)
ch = b[target]
del b[target]
b1 = [ch] + b
b2 = b + [ch]
stk.clear()
target = -1
for i in range(n):
	if b1[i] == '(':
		stk.append('(')
	else:
		if len(stk) == 0:
			target = i
			break
		stk.pop()
if len(stk) == 0 and target == -1:
	print('Yes')
	exit(0)
stk.clear()
target = -1
for i in range(n):
	if b2[i] == '(':
		stk.append('(')
	else:
		if len(stk) == 0:
			target = i
			break
		stk.pop()
if len(stk) == 0 and target == -1:
	print('Yes')
	exit(0)
print('No')


n = int(input())
b = input()
stack = []
c1 = 0
c2 = 0
for c in b:
	if c == '(':
		c1 += 1
	else:
		c2 += 1
for c in b:
	if c == '(':
		stack.append(c)
	if c == ')':
		if stack:
			stack.pop()
if n % 2 == 0:
	if c1 != c2:
		print('No')
	elif len(stack) > 1:
		print('No')
	else:
		print('Yes')
else:
	print('No')