#include<bits/stdc++.h>
using namespace std;

struct Box{
    int cap, amt;
    Box(): amt(0) {}
};

struct Query{
    int t, x, d;
};

int main(){
    int N, Q;
    cin >> N;
    vector<Box> boxes(N);
    int in;
    for(int i=0; i<N; i++){
        cin >> in;
        boxes[i].cap = in;
    }
    cin >> Q;
    int t, x, d;
    vector<Query> queries(Q);
    for(int i=0; i<Q; i++){
        cin >> t >> x >> d;
        queries[i].t = t;
        queries[i].x = x;
        queries[i].d = d;
    }
    for(int i=0; i<Q; i++){
        int t = queries[i].t, x = queries[i].x, d = queries[i].d;
         if(t == 1){
            boxes[x-1].amt += d;
            if(boxes[x-1].amt > boxes[x-1].cap){
                cout << x << endl;
                return 0;
            }
        }
        else{
            boxes[x-1].amt -= d;
            if(boxes[x-1].amt < 0){
                cout << x << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}
