#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
vi t, m;
int T, N, dp[111][33];

int solve(int i, int j) 
{
	j %= T;
	if (i == 110) return 0;
	if (dp[i][j] >= 0) return dp[i][j];
	int res;
	if (t[j] > m[i]) res = solve(i + 1, 1) + 1;
	else res = min(solve(i + 1, 1) + 1, solve(i + 1, j + 1));
	return dp[i][j] = res;
}

int main()
{
	while (cin >> T, T)
	{
		t.clear(), m.clear();
		MS(dp, -1);
		REP(i, T)
		{
			int a; cin >> a;
			a--;
			t.push_back(a);
		}
		cin >> N;
		m.resize(111, INF);
		REP(i, N) 
		{
			int a, b; cin >> a >> b;
			a--; b--;
			chmin(m[a], b);
		}
		cout << solve(0, 0) << endl;
	}
	return 0;
}