#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

int main()
{
	while (1)
	{
		int T; cin >> T;
		if (T == 0) return 0;

		int t[30];
		rep(i, 0, T) cin >> t[i];

		int N; cin >> N;

		map<int, int> DM;
		rep(i, 0, N)
		{
			int D, M;
			cin >> D >> M;
			if(DM.find(D) == DM.end())
				DM[D] = M;
			else
				DM[D] = min(DM[D], M);
		}

		vvi dp(105, vi(T, INF));
		dp[1][0] = 0;

		rep(d, 1, 101) rep(j, 0, T)
		{
			if (dp[d][j] == INF) continue;

			dp[d + 1][1] = min(dp[d + 1][1], dp[d][j] + 1);
			
			if (DM.find(d) == DM.end())
			{
				dp[d + 1][(j + 1) % T] = min(dp[d + 1][(j + 1) % T], dp[d][j]);
			}
			else
			{
				if (t[j] <= DM[d])
				{
					dp[d + 1][(j + 1) % T] = min(dp[d + 1][(j + 1) % T], dp[d][j]);
				}
			}
		}

		ll ans = INF;
		rep(j, 0, T) ans = min(ans, dp[101][j]);
		cout << ans << endl;
	}
}