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


typedef long long ll;


int main(){
  ll t,n;
  while(cin>>t && t){
  vector<ll> a(t);
  for(int i=0;i<t;i++){cin>>a[i];}
  cin>>n;
  vector<ll> inter(112,23);
  for(int i=0;i<n;i++){
    ll d,t;
    cin>>d>>t;
    d--;
    inter[d]=min(inter[d],t);
  }
  ll INF=100000000;
  vector<ll> dp(112,INF);
  dp[0]=-1;
  for(int i=0;i<110;i++){
    for(int j=0;i+j<110;j++){
      if(inter[i+j]>=a[j%t]){dp[i+j+1]=min(dp[i+j+1],dp[i]+1);}
      else{break;}
    }
  }
  cout<<dp[105]<<endl;
  }



  return 0;
}

