#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long n, q, ans, a[maxn], pp[maxn], SS[maxn], TT[maxn], UU[maxn];
map<long long, long long> hasq[maxn];
void solve() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    ans += a[i];
  }
  scanf("%lld", &q);
  for (int i = 1; i <= q; i++) scanf("%lld%lld%lld", &SS[i], &TT[i], &UU[i]);
  for (int i = 1; i <= q; i++) {
    if (hasq[SS[i]][TT[i]]) {
      if (pp[hasq[SS[i]][TT[i]]] <= a[hasq[SS[i]][TT[i]]]) ans++;
      pp[hasq[SS[i]][TT[i]]]--;
    }
    hasq[SS[i]][TT[i]] = UU[i];
    if (pp[UU[i]] < a[UU[i]]) ans--;
    pp[UU[i]]++;
    printf("%lld\n", ans);
  }
}
int main() {
  solve();
  return 0;
}
