#include <iostream>
#include <vector>
using namespace std;

const int MAX_N = 200005;
const int R = 256 * 1024;

vector<int> P[MAX_N];
int n, q, B[MAX_N], T[2 * R];

int get_min(int x, int y) {
    x += R;
    y += R;
    int w = min(T[x], T[y]);
    while(x / 2 != y / 2) {
        if(x % 2 == 0) w = min(w, T[x + 1]);
        if(y % 2 == 1) w = min(w, T[y - 1]);
        x /= 2;
        y /= 2;
    }
    return w;
}

void update(int x, int w) { 
    x += R;
    T[x] = w;
    while(x > 1) {
        x /= 2;
        T[x] = min(T[2 * x], T[2 * x + 1]);
    }
}

int main() {
    for(int i = 1; i < 2 * R; i++) T[i] = MAX_N;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> B[i];
    cin >> q;
    for(int i = 1; i <= q; i++) {
        int l, r;
        cin >> l >> r;
        P[l].push_back(r);
    }
    int result = 0;
    for(int i = 1; i <= n; i++) if(B[i] == 0) result++;
    update(0, 0);
    for(int i = 1; i <= n; i++) {
        for(int r : P[i]) update(r, get_min(i - 1, r));
        update(i, min(T[i + R], T[i - 1 + R] + (B[i] == 1 ? 1 : -1)));
    }
    cout << result + T[n + R];
    
    return 0;
}
