#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }
 
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}
 
template<typename T> T inf;
template<> constexpr int inf<int> = 1e9;
template<> constexpr ll inf<ll> = 1e18;
template<> constexpr ld inf<ld> = 1e30;
 
struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};
 
template <typename T>
class StarrySkyTree {
  const int n;
  vector<T> data, lazy;
  int expand(int n) const { return n == 1 ? n : expand((n + 1) / 2) * 2; }
public:
  StarrySkyTree(int m) : n(expand(m)), data(n * 2, 0), lazy(n * 2, 0) {}
  void add(int l, int r, T val) {
    l += n; r += n;
    const int left = l, right = r;
    while (l != r) {
      if (l % 2) { lazy[l] += val; data[l++] += val; }
      if (r % 2) { lazy[--r] += val; data[r] += val; }
      l /= 2; r /= 2;
    }
    l = left; r = right - 1;
    while (l /= 2, r /= 2) {
      data[l] = min(data[l * 2], data[l * 2 + 1]) + lazy[l];
      data[r] = min(data[r * 2], data[r * 2 + 1]) + lazy[r];
    }
  }
  T minimum(int l, int r) const {
    if (l == r) return inf<T>;
    l += n; r += n;
    T res1 = inf<T>, res2 = inf<T>;
    while (l != r) {
      if (l % 2) res1 = min(res1, data[l++]);
      if (r % 2) res2 = min(res2, data[--r]);
      l /= 2; r /= 2; res1 += lazy[l - 1]; res2 += lazy[r];
    }
    --l;
    while (l /= 2, r /= 2) { res1 += lazy[l]; res2 += lazy[r]; }
    return min(min(res1, res2), inf<T>);
  }
};

vector<int> rs[256000];
 
void solve(ll N, vector<ll> b, ll Q, vector<ll> l, vector<ll> r) {
  StarrySkyTree<int> seg(N + 1);
  seg.add(1, N + 1, int(1e8));
  REP(i,Q) {
    rs[l[i] - 1].push_back(r[i]);
  }
  REP(i,N) {
    for (int r: rs[i]) {
      int mi = seg.minimum(0, r);
      int def = seg.minimum(r, r + 1);
      if (mi < def) seg.add(r, r + 1, mi - def);
    }
    seg.add(0, i + 1, b[i]);
    seg.add(i + 1, N + 1, 1 - b[i]);
  }
  cout << seg.minimum(0, N + 1) << endl;
}
 
int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll Q;
	scanf("%lld", &N);
	vector<ll> b(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &b[i]);
	}
	scanf("%lld", &Q);
	vector<ll> l(Q-1+1);
	vector<ll> r(Q-1+1);
	for (int i = 0 ; i <= Q-1 ; i++) {
	  scanf("%lld", &l[i]);
	  scanf("%lld", &r[i]);
	}
	solve(N, b, Q, l, r);
	return 0;
}


Measured memory_bytes: 23680