#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 200005, L = 262144, inf = 1e9;

int n, m, s[N];
pii a[N];

struct minseg {
	int v[2*L];
	void init () {
		for(int i=2*L;i--;) v[i] = inf;
	}
	void upd (int P, int V) {
		P += L;
		while(P) {
			v[P] = min(v[P], V);
			P /= 2;
		}
	}
	int get (int S, int E) {
		S += L; E += L;
		int R = inf;
		while(S <= E) {
			if(S%2 == 1) R = min(R, v[S++]);
			if(E%2 == 0) R = min(R, v[E--]);
			S /= 2; E /= 2;
		}
		return R;
	}
} b, w;

int hmd (int I, int V) {
	if(!V) return s[I];
	return I - s[I];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&s[i]);
		s[i] += s[i-1];
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++) {
		scanf("%d%d",&a[i].X,&a[i].Y);
	}
	sort(a+1, a+1+m);
	b.init(); w.init();
	w.upd(0, 0);
	for(int i=1;i<=m;i++) {
		int B = b.get(a[i].X-1, a[i].Y-1);
		int W = w.get(0, a[i].X-1);
		b.upd(a[i].Y, B);
		w.upd(a[i].Y, B + hmd(a[i].Y, 1) - hmd(a[i].Y, 0));
		b.upd(a[i].Y, W + hmd(a[i].X-1, 0) - hmd(a[i].X-1, 1));
		w.upd(a[i].Y, W + hmd(a[i].X-1, 0) - hmd(a[i].X-1, 1) + hmd(a[i].Y, 1) - hmd(a[i].Y, 0));
	}
	printf("%d\n", w.get(0,n) + s[n]);
}
