#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
ll n;
vector< pair<ll,ll> > adj[N];
vector< pair< pair<ll,ll> , ll > >wt;
bool cmp( pair< pair<ll,ll> , ll > a,pair< pair<ll,ll> ,ll >b){
    return a.second<b.second;
}
ll par[N],sz[N];
void init(){
    for(ll i=0;i<N;i++)par[i]=i,sz[i]=1;
}
ll dsu_parent(ll node){
    if(node==par[node])return node;
    return par[node]=dsu_parent(par[node]);
}
void dsu_union(ll a,ll b){
    a=dsu_parent(a);
    b=dsu_parent(b);
    if(a==b)return;
    if(sz[a]<sz[b])swap(a,b);
    sz[a]+=sz[b];
    par[b]=a;
}
ll func(){
    ll ans = 0;
    for(ll i=1;i<=n;i++)for(auto &ele:adj[i])wt.push_back( { {i,ele.second} , ele.first} );
    sort(wt.begin(),wt.end(),cmp);
    init();
    for(auto &edges:wt){
       // cout<<edges.first.first<<" "<<edges.first.second<<" "<<edges.second<<endl;
        ll u=edges.first.first,v=edges.first.second,w=edges.second;
        if(dsu_parent(u)==dsu_parent(v))continue;
        ans+=w;
        dsu_union(u,v);
    }
    return ans;
}
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    cin>>n;
    pair<ll,ll> x[n],y[n];
    for(ll i=0;i<n;i++)cin>>x[i].first>>y[i].first,x[i].second=y[i].second=i+1;
    sort(x,x+n);
    sort(y,y+n);
    for(ll i=1;i<n;i++){
        adj[x[i].second].push_back({x[i].first-x[i-1].first , x[i-1].second});
        adj[x[i-1].second].push_back({x[i].first-x[i-1].first , x[i].second});

        adj[y[i].second].push_back({y[i].first-y[i-1].first , y[i-1].second});
        adj[y[i-1].second].push_back({y[i].first-y[i-1].first , y[i].second});
    }
    cout<<func();
}



#include <bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 1e6 + 7;
int n, sumtop;

struct T {
  int top;
  int mn;
};

bool cmp1(T a, T b) {
  return a.mn > b.mn;
}

bool cmp2(T a, T b) {
  return min(a.mn, a.top + b.mn) > min(b.mn, b.top + a.mn);
 ///return a.top - a.mn > b.top - b.mn;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<T> a, b;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    int top = 0, mn = 0;
    for (auto &ch : s) {
      if (ch == '(') {
        top++;
      } else {
        top--;
      }
      mn = min(mn, top);
    }
    if (top >= 0) {
      a.push_back({top, mn});
    } else {
      b.push_back({top, mn});
    }
    sumtop += top;
  }
  if (sumtop != 0) {
    cout << "No\n";
    return 0;
  }
  sort(a.begin(), a.end(), cmp1);
  sort(b.begin(), b.end(), cmp2);
  int cur = 0;
  for (auto &it : a) {
    if (cur + it.mn < 0) {
      cout << "No\n";
      return 0;
    }
    cur += it.top;
  }
  for (auto &it : b) {
    if (cur + it.mn < 0) {
      cout << "No\n";
      return 0;
    }
    cur += it.top;
  }
  cout << "Yes\n";
  return 0;
}
