#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,c[1001],cc[1001];
  int q,t,x,d;
  rep(i,1001) cc[i]=0;
  cin>>n;
  repi(i,1,n+1) cin>>c[i];
  cin>>q;
  rep(i,q){
    cin>>t>>x>>d;
    if(t==1){
      cc[x]+=d;
      if(cc[x]>c[x]){cout<<x<<endl;return 0;}
    }
    else{
      cc[x]-=d;
      if(cc[x]<0){cout<<x<<endl;return 0;}
    }
  }
  cout<<0<<endl;
    

  return 0;
}




