#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; double w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int T; cin >> T;
		if (T == 0) break;
		vector<int> t(T);
		for (int j = 0; j < T; j++)
			cin >> t[j];
		int N; cin >> N;
		vector<int> a(100, 24);
		while (N--) {
			int D, M; cin >> D >> M;
			a[D - 1] = min(a[D - 1], M);
		}
		vector<int> dp(T, INT_MAX);
		dp[0] = 0;
		for (int d = 0; d < 100; d++) {
			for (int j = 0; j < T; j++)
				if (t[j] > a[d])
					dp[j] = INT_MAX;
			vector<int> _dp(T);
			for (int j = 0; j < T; j++)
				_dp[(j + 1) % T] = dp[j];
			int mini = INT_MAX;
			for (int j = 0; j < T; j++)
				mini = min(mini, dp[j]);
			_dp[0] = min(_dp[0], mini + 1);
			dp = _dp;
		}
		int mini = INT_MAX;
		for (int j = 0; j < T; j++)
			mini = min(mini, dp[j]);
		cout << mini << endl;
	}
}