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

using ll=long long;
 
constexpr long long INF64 = 1e18;

int main(){
  int N;
  cin >> N;
  vector<int> cap(N);

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

  int Q;
  cin >> Q;
  vector<int> box(N);
  for (int i = 0; i < Q; i++) {
    int t, x, d;
    cin >> t >> x >> d; x--;
    switch (t) {
      case 1:
        box[x] += d;
        if (cap[x] < box[x]) {
          cout << x + 1 << endl;
          return 0;
        }
        break;
      case 2:
        box[x] -= d;
        if (box[x] < 0) {
          cout << x + 1 << endl;
          return 0;
        }
        break;
    }
  }
  cout << 0 << endl;
  return 0;
}
