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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int T;
  while(cin>>T && T){
    vector<int> t(T);
    REP(i, T) cin>>t[i];
    int N;
    cin>>N;
    int start[100] = {};
    REP(i, 100) start[i] = 24;
    REP(i, N) {
      int D, M;
      cin>>D>>M;
      start[D-1] = min(start[D-1], M);
    }
    int dp[101][30] = {};
    REP(i, 101) fill(dp[i], dp[i] + 30, INF);
    dp[0][T - 1] = 0;
    REP(i, 100){
      REP(j, T)if(dp[i][j] < INF){
        int k = (j + 1) % T;
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + 1);
        if(t[k] <= start[i]) dp[i + 1][k] = min(dp[i + 1][k], dp[i][j]);
      }
    }
    int ans = INF;
    REP(i, T) ans = min(ans, dp[100][i]);
    cout<<ans<<endl;
  }
  return 0;
}