#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;
int n, m, a[N];
long long ans = 0;
map<pair<int, int>, int> mp;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    scanf("%d", &a[i]);
    ans += a[i];
  }
  scanf("%d", &m);
  for (int i = (1); i <= (m); i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    if (mp[make_pair(x, y)])
      a[mp[make_pair(x, y)]]++, ans += (a[mp[make_pair(x, y)]] > 0),
          mp[make_pair(x, y)] = 0;
    if (z) ans -= (a[z] > 0), a[z]--, mp[make_pair(x, y)] = z;
    printf("%I64d\n", ans);
  }
  return 0;
}
