func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   int a[maxn], cnt[maxn], n, q;   long long ans = 0;   map<pair<long long, long long>, int> mp;   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       ans += a[i];     }     cin >> q;     long long s, t, u;     while (q--) {       cin >> s >> t >> u;       if (mp.find(pair<long long, long long>(s, t)) != mp.end()) {         int c = mp[pair<long long, long long>(s, t)];         if (cnt[c] <= a[c]) ans++;         cnt[c]--;         mp.erase(pair<long long, long long>(s, t));       }       if (u != 0) {         mp[pair<long long, long long>(s, t)] = u;         if (cnt[u] < a[u]) ans--;         cnt[u]++;       }       cout << ans << endl;     }     return 0;   }   