#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> c(n),v(n,0);
  for(int i=0;i<n;i++) cin>>c[i];
  int q;
  cin>>q;
  while(q--){
    int t,x,d;
    cin>>t>>x>>d;
    x--;
    if(t==1) v[x]+=d;
    if(t==2) v[x]-=d;
    if(v[x]<0||v[x]>c[x]){
      cout<<x+1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
  return 0;
}

