#include <bits/stdc++.h>
using namespace std;
#define N 1000
int c[N+1];
int a[N+1];
int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
		a[i] = 0;
	}
	int q;
	cin >> q;
	while(q--) {
		int t, x, d;
		cin >> t >> x >> d;
		if(t == 1) {
			a[x] += d;
			if(a[x] > c[x]) {
				cout << x << endl;
				return 0;
			}
		} else {
			a[x] -= d;
			if(a[x] < 0) {
				cout << x << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
	return 0;
}
