/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.21 02:11:21
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    vector<ll> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    n++;
    int l;cin >> l;
    x.push_back(x[x.size()-1] + l);
    vector<int> next(n);
    for (int i = 0; i < n; i++) {
        auto t = upper_bound(x.begin(), x.end(), x[i] + l);
        t--;
        next[i] = t - x.begin();
    }
    vector<vector<int>> doubling(32,vector<int>(n));
    for (int i = 0; i < n; i++) {
        doubling[0][i] = next[i];
    }
    for (int i = 1; i < 32; i++) {
        for (int j = 0; j < n; j++) {
            doubling[i][j] = doubling[i-1][doubling[i-1][j]];
        }
    }
    
    int q;cin >> q;
    while(q--) {
        int a,b;cin >> a >> b;
        a--;b--;
        if (b < a) swap(a,b);
        int ans = 0;
        for (int i = 31; i >= 0; i--) {
            if (doubling[i][a] <= b) {
                a = doubling[i][a];
                ans += (1 << i);
            } 
        }
        if (a != b) ans++; 
        cout << ans << endl;
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> S(n);
  vector<vector<pair<int, int>>> v(4);
  int sum = 0;
  rep(i, n) {
    cin >> S[i];
    int cnt=0, mn=0;
    for(char c: S[i]) {
      cnt += (c=='(' ? 1 : -1);
      mn = min(cnt, mn);
    }
    sum += cnt;
    if(mn == 0 && cnt >= 0) {
      v[0].push_back({mn, cnt});
    } else if(mn < 0 && cnt >= 0) {
      v[1].push_back({mn, cnt});
    } else if(mn == cnt && cnt <= 0) {
      v[2].push_back({mn, cnt});
    } else {
      v[3].push_back({mn, cnt});
    }
  }
  auto no = [&]() {
    cout << "No" << "\n";
    exit(0);
  };
  if(sum != 0) no();
  sum = 0;
  for(auto p: v[0]) {
    sum += p.second;
  }
  sort(all(v[1]), greater<pair<int, int>>());
  for(auto p: v[1]) {
    if(sum + p.first < 0) no();
    sum += p.second;
  }
  sum = 0;
  for(auto p: v[2]) {
    sum += -p.second;
  }
  sort(all(v[3]), [&](pair<int, int> p1, pair<int, int> p2) {
      if(p1.first == p2.first) {
        return p1.second < p2.second;
      }
      return p1.first-p1.second > p2.first-p2.second;
    });
  for(auto p: v[3]) {
    if(sum + p.first-p.second < 0) no();
    sum += -p.second;
  }
  cout << "Yes" << "\n";
  return 0;
}
