#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

const int N = 110;
const int INF = 1e9;
int G[N][N];

int main(){
	int n;
	while (cin >> n, n){
		vector<int> v(n);
		rep(i, n) cin >> v[i];
		rep(i, N) v.push_back(v[i]);
		rep(i, N) rep(j, N) if (i < j) G[i][j] = INF;
		int t;
		cin >> t;
		vector<int> m(N, 23);
		rep(i, t){
			int d, x;
			cin >> d >> x;
			m[d - 1] = min(m[d - 1], x);
		}
		rep(i, N){
			int x = i, j = 0;
			while (x < N && v[j++] <= m[x++]);
			G[i][x-1] = 1;
		}
		rep(i, N) rep(j, N) rep(k, N) G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
		cout << G[0][N - 1] - 1 << endl;
	}

	return 0;
}