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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int T, N;
int t[32];
int M[128];
int dp[32][128];

int dfs(int n, int d){
  if(d==100) return 0;
  int &res = dp[n][d];
  if(res >= 0) return res;
  //  if(d<=N) cout << n << " " << d << endl;
  res = INF;
  if(t[n] <= M[d]) res = min(res, dfs((n+1)%T, d+1));
  res = min(res, dfs(1, d+1)+1);
  return res;
}

int main(){
  while(scanf("%d", &T) && T){
    memset(dp, -1, sizeof(dp));
    fill(M, M+100, 24);
    rep(i,T) scanf("%d", t+i);
    scanf("%d",&N);
    rep(i,N){
      int t,m;
      scanf("%d%d", &t,&m); t--;
      M[t] = min(M[t],m);
    }

    printf("%d\n", dfs(0, 0));
  }
  return 0;
}