#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  vector<long long> b(n + 1);
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
    sum += a[i];
  }
  long long q;
  cin >> q;
  map<pair<long long, long long>, long long> m;
  while (q--) {
    long long l, r, s;
    cin >> l >> r >> s;
    b[m[make_pair(l, r)]]++;
    if (b[m[make_pair(l, r)]] > 0 && m[make_pair(l, r)]) {
      sum++;
    }
    m[make_pair(l, r)] = s;
    b[m[make_pair(l, r)]]--;
    if (b[m[make_pair(l, r)]] >= 0 && m[make_pair(l, r)]) {
      sum--;
    }
    cout << sum << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
