#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

const int MAX_T = 30;
const int MAX_DAY = 100;

int T, N;
int t[MAX_T];
int m[MAX_DAY]; // the first meeting time of the day
int memo[MAX_DAY][MAX_T];
int dfs(int day, int step) {
    if (day == MAX_DAY) return 0;
    if (memo[day][step] != -1) return memo[day][step];
    if (m[day] < t[step]) return inf;

    return memo[day][step] = min(dfs(day + 1, (step + 1) % T), dfs(day + 1, 0) + 1);
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    while (cin >> T, T) {
        rep(i, T) cin >> t[i];
        cin >> N;
        fill(m, m + MAX_DAY, inf);
        rep(i, N) {
            int D, M;
            cin >> D >> M;
            D--;
            m[D] = min(m[D], M);
        }
        rep(i, MAX_DAY) fill(memo[i], memo[i] + MAX_T, -1);
        cout << dfs(0, 0) << endl;
    }
}