#include<iostream>
using namespace std;

int main()
{
    int n, q, t, x, d;
    
    cin >> n;

    int c[n], box[n];
    for( int i = 0; i < n; i++ )
    {
        cin >> c[i];
        box[i] = 0;
    }

    cin >> q;

    bool judge = true;
    int res = 0;
    for( int i = 0; i < q; i++ )
    {
        cin >> t >> x >> d;
        //収穫
        if( t == 1 && judge )
        {
            box[x-1] += d;
            if( box[x-1] > c[x-1] )
            {
                res = x;
                judge = false;
            }
        }
        else if( t == 2 && judge )
        {
            box[x-1] -= d;
            if( box[x-1] < 0 )
            {
                res = x;
                judge = false;
            }
        }
        else;
    }

    cout << res << endl;

    return 0;
}
