#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

// dp[i][j] = i日目で周期がjのときの最低回数（無理ならINF）
int dp[101][31];

int main() {
  int T;
  while(cin>>T,T) {
    int t[T];
    REP(i,T)cin>>t[i];
    int N;cin>>N;
    int D[N], M[N];
    int A[101];
    REP(i,101) A[i]=23;
    REP(i,N) {
      cin >> D[i] >> M[i];
      A[D[i]] = min(A[D[i]], M[i]);
    }
    REP(i,101)REP(j,T+1)dp[i][j]=INF;
    dp[0][0] = 0;
    REP(i,100) {
      REP(j,T) {
        //cout << i << " " << j << " " << t[j] << " " << A[i] << " " << dp[i][j] << endl;
        if (t[j]<=A[i+1]) {       // ok
          dp[i+1][(j+1)%T] = min(dp[i+1][(j+1)%T], dp[i][j]);
        }
        dp[i+1][1] = min(dp[i+1][1], dp[i][j]+1);
      }
    }
    int ans = INF;
    REP(i,T) ans = min(ans, dp[100][i]);
    assert(ans!=INF);
    cout << ans << endl;
  }
}