#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod1 1000000007
#define MOD 1000000037
#define mod 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

vector<int>segv;
vector<int>segtree;
map<int,set<int> >m;

int build(int l,int r,int currpos)
{
    if(l==r)
    {
        segtree[currpos]=segv[l];
        return segv[l];
    }
    int mid=(l+r)/2;
    segtree[currpos]=min(build(l,mid,2*currpos+1),build(mid+1,r,2*currpos+2));
    return segtree[currpos];
}

int getmin(int l,int r,int currpos1,int currpos2,int ind)
{
    if(r<currpos1 or l>currpos2)
        return INF;
    if(l<=currpos1 and r>=currpos2)
        return segtree[ind];
    int mid=(currpos1+currpos2)/2;
    return min(getmin(l,r,currpos1,mid,2*ind+1),getmin(l,r,mid+1,currpos2,2*ind+2));
}

int update(int pos,int updval,int currpos1,int currpos2,int ind)
{
    if(pos<currpos1 or pos>currpos2)
        return segtree[ind];
    if(currpos1==currpos2 and pos==currpos2)
    {
        segtree[ind]=updval;
        return updval;
    }
    if(currpos1==currpos2)
        return segtree[ind];
    int mid=(currpos1+currpos2)/2;
    segtree[ind]=min(update(pos,updval,currpos1,mid,2*ind+1),update(pos,updval,mid+1,currpos2,2*ind+2));
    return segtree[ind];
}

pair<int,int> func(string s)
{
    stack<char>st;
    for(int i=0;i<s.length();i++)
    {
        if(st.empty() or s[i]=='(')
            st.push(s[i]);
        else
        {
            char c=st.top();
            if(c=='(')
                st.pop();
            else
                st.push(')');
        }
    }
    pair<int,int>ans={0,0};
    while (!st.empty())
    {
        char c=st.top();
        st.pop();
        if(c=='(')
            ans.first+=1;
        else
            ans.second+=1;
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    vector<string>v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    vector<pair<int,int> >v1;
    int l=0,r=0;
    for(int i=0;i<n;i++)
    {
        pair<int,int>t=func(v[i]);
        if(t.first+t.second==0)
            continue;
        else if(t.first==0)
            r+=t.second;
        else if(t.second==0)
            l+=t.first;
        else
        {
            pair<int,int>p={t.second,t.first};
            v1.push_back(p);
        }
    }
    //cout << l << " " << r << " " << v1.size() << endl;
    int f=1;
    if(v1.size()>0)
    {
        sort(v1.begin(),v1.end());
        vector<int>arr1(v1.size());
        segv.resize(v1.size());
        for(int i=0;i<v1.size();i++)
        {
            int t=v1[i].second-v1[i].first;
            segv[i]=-t;
            arr1[i]=v1[i].first;
            m[-t].insert(i);
        }
        int si=v1.size();
        int temp=ceil(log2(si));
        segtree.resize(pow(2,temp+1));
        build(0,si-1,0);
        int len=v1.size();
        while(len>0 and f==1)
        {
            int ind=lower_bound(arr1.begin(),arr1.end(),l+1)-arr1.begin();
            if(ind==0)
            {
                f=0;
                break;
            }
            int imp=getmin(0,ind-1,0,si-1,0);
            //cout << ind << " " << imp << endl;
            if(imp==INF)
            {
                f=0;
                break;
            }
            l+=-imp;
            set<int>:: iterator itr=m[imp].begin();
            int pos=*itr;
            m[imp].erase(itr);
            update(pos,INF,0,si-1,0);
            len-=1;
        }
    }
    if(f==0 or l!=r)
        cout << "No" << endl;
    else
        cout << "Yes" << endl; 
}

Measured memory_bytes: 34276