#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return 0;
}();
class pr {
 public:
  int s, t;
  pr(const int& _s, const int& _t) : s(_s), t(_t){};
  bool operator<(const pr& b) const { return s != b.s ? s < b.s : t < b.t; }
};
const int maxn = 2e5 + 7;
int a[maxn], b[maxn];
int main() {
  map<pr, int> mp;
  int n;
  cin >> n;
  long long tot = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    tot += a[i];
  }
  int m, sum = 0;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int s, t, u;
    cin >> s >> t >> u;
    auto p = mp.insert(pair<pr, int>(pr(s, t), 0)).first;
    if (p->second != 0) {
      b[p->second]--;
      if (b[p->second] < a[p->second]) sum--;
    }
    if (u != 0) {
      p->second = u;
      b[u]++;
      if (b[u] <= a[u]) sum++;
    } else
      mp.erase(p);
    cout << tot - sum << endl;
  }
}
