
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

int hako[1000];
int N, C[1000], Q;
int t[100000], x[100000], d[100000];

int main() {
	
	for (int i = 0; i < 1000; i++) {
		hako[i] = 0;
	}

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C[i];

	}
	cin >> Q;

	for (int i = 0; i < Q; i++) {
		cin >> t[i] >> x[i] >> d[i];
	}

	for (int i = 0; i < Q; i++) {
		if (t[i] == 1) {
			hako[x[i] - 1] += d[i];
			if (hako[x[i] - 1] > C[x[i] - 1]) {
				cout << x[i] << endl;
				return 0;
			}
		}
		if (t[i] == 2) {
			hako[x[i] - 1] -= d[i];
			if (hako[x[i] - 1] < 0) {
				cout << x[i] << endl;
	
			
				return 0;
			}
		}
	}
	cout << 0 << endl;


	return 0;
}
