#include<iostream>
#include<vector>
using namespace std;
int N;
vector<int> have;
vector<int> maxn;
int func(){
	int Q;
	cin >> Q;
	for(int i=0;i<Q;++i){
		int t, x, d;
		cin >> t >> x >> d;
		if(t == 1){
			have[x] += d;
			if(have[x] > maxn[x])return x;
		}else{
			have[x] -= d;
			if(have[x] < 0)return x;
		}
	}	
	return 0;
}
int main(){
	cin >> N;
	have.resize(N+1, 0);
	maxn.resize(N+1);
	for(int i=1;i<=N;++i){
		cin>>maxn[i];
	}
	cout << func() << endl;	
	return 0;
}

