def CNT(A):

    tmp, Min = 0, 0

    for a in A:

        if a == '(': tmp += 1

        else: tmp -= 1

        Min = min(Min, tmp)

    return (-Min, tmp-Min)



N = int(eval(input()))

S = [eval(input()) for _ in range(N)]

T = [CNT(s) for s in S]



pls = []

mis = []

for l, r in T:

    if l <= r: pls.append((l, r))

    else: mis.append((l, r))



pls.sort(key=lambda a: a[0])

mis.sort(key=lambda a: a[1], reverse=True)

totl= pls + mis



levl = 0

for l, r in totl:

    levl -= l

    if levl < 0:

        print('No')

        exit()

    levl += r



print(('Yes' if levl==0 else 'No'))
def main():

  ## IMPORT MODULE

  #import sys



  #sys.setrecursionlimit(100000)

  #input=lambda :sys.stdin.readline().rstrip()



  #f_inf=float("inf")

  #MOD=10**9+7

  

  if 'get_ipython' in globals(): 

    ## SAMPLE INPUT

    n = 4

    S = ['((()))', '((((((', '))))))', '()()()']



  else:

    ## INPUT 

    n = int(eval(input()))

    #a, b = map(int, input().split())

    S = [eval(input()) for _ in range(n)]



  ## SUBMITION CODES HERE

  def CNT(A):

    tmp, Min = 0, 0

    for a in A:

        if a == '(': tmp += 1

        else: tmp -= 1

        Min = min(Min, tmp)

    return (-Min, tmp-Min)

  

  T = [CNT(s) for s in S]



  pls = []

  mis = []

  for l, r in T:

    if l <= r: pls.append((l, r))

    else: mis.append((l, r))



  pls.sort(key=lambda a: a[0])

  mis.sort(key=lambda a: a[1], reverse=True)

  total = pls + mis



  levl = 0

  for l, r in total:

    levl -= l

    if levl < 0:

        print('No')

        exit()

    levl += r



  print(('Yes' if levl == 0 else 'No'))

    

main()
def CNT(A):
    tmp, Min = 0, 0
    for a in A:
        if a == "(":
            tmp += 1
        else:
            tmp -= 1
        Min = min(Min, tmp)
    return (-Min, tmp - Min)


N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
T = [CNT(s) for s in S]
pls = []
mis = []
for l, r in T:
    if l <= r:
        pls.append((l, r))
    else:
        mis.append((l, r))
pls.sort(key=lambda a: a[0])
mis.sort(key=lambda a: a[1], reverse=True)
totl = pls + mis
levl = 0
for l, r in totl:
    levl -= l
    if levl < 0:
        print("No")
        exit()
    levl += r
print(("Yes" if levl == 0 else "No"))

def main():
    ## IMPORT MODULE
    # import sys
    # sys.setrecursionlimit(100000)
    # input=lambda :sys.stdin.readline().rstrip()
    # f_inf=float("inf")
    # MOD=10**9+7
    if "get_ipython" in globals():
        ## SAMPLE INPUT
        n = 4
        S = ["((()))", "((((((", "))))))", "()()()"]
    else:
        ## INPUT
        n = int(eval(input()))
        # a, b = map(int, input().split())
        S = [eval(input()) for _ in range(n)]
    ## SUBMITION CODES HERE
    def CNT(A):
        tmp, Min = 0, 0
        for a in A:
            if a == "(":
                tmp += 1
            else:
                tmp -= 1
            Min = min(Min, tmp)
        return (-Min, tmp - Min)

    T = [CNT(s) for s in S]
    pls = []
    mis = []
    for l, r in T:
        if l <= r:
            pls.append((l, r))
        else:
            mis.append((l, r))
    pls.sort(key=lambda a: a[0])
    mis.sort(key=lambda a: a[1], reverse=True)
    total = pls + mis
    levl = 0
    for l, r in total:
        levl -= l
        if levl < 0:
            print("No")
            exit()
        levl += r
    print(("Yes" if levl == 0 else "No"))


main()

-def CNT(A): -    tmp, Min = 0, 0 -    for a in A: -        if a == "(": -            tmp += 1 +def main(): +    ## IMPORT MODULE +    # import sys +    # sys.setrecursionlimit(100000) +    # input=lambda :sys.stdin.readline().rstrip() +    # f_inf=float("inf") +    # MOD=10**9+7 +    if "get_ipython" in globals(): +        ## SAMPLE INPUT +        n = 4 +        S = ["((()))", "((((((", "))))))", "()()()"] +    else: +        ## INPUT +        n = int(eval(input())) +        # a, b = map(int, input().split()) +        S = [eval(input()) for _ in range(n)] +    ## SUBMITION CODES HERE +    def CNT(A): +        tmp, Min = 0, 0 +        for a in A: +            if a == "(": +                tmp += 1 +            else: +                tmp -= 1 +            Min = min(Min, tmp) +        return (-Min, tmp - Min) + +    T = [CNT(s) for s in S] +    pls = [] +    mis = [] +    for l, r in T: +        if l <= r: +            pls.append((l, r)) -            tmp -= 1 -        Min = min(Min, tmp) -    return (-Min, tmp - Min) +            mis.append((l, r)) +    pls.sort(key=lambda a: a[0]) +    mis.sort(key=lambda a: a[1], reverse=True) +    total = pls + mis +    levl = 0 +    for l, r in total: +        levl -= l +        if levl < 0: +            print("No") +            exit() +        levl += r +    print(("Yes" if levl == 0 else "No")) -N = int(eval(input())) -S = [eval(input()) for _ in range(N)] -T = [CNT(s) for s in S] -pls = [] -mis = [] -for l, r in T: -    if l <= r: -        pls.append((l, r)) -    else: -        mis.append((l, r)) -pls.sort(key=lambda a: a[0]) -mis.sort(key=lambda a: a[1], reverse=True) -totl = pls + mis -levl = 0 -for l, r in totl: -    levl -= l -    if levl < 0: -        print("No") -        exit() -    levl += r -print(("Yes" if levl == 0 else "No")) +main()