#include using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=300000000; ll mod=998244353; int main(){ ll n,m; cin >> n >> m; vectora(m); ll ans=0; for (ll i = 0; i < m; i++) { cin >> a[i]; ans+=a[i]*a[i]; } ll q; cin >> q; for (ll i = 0; i < q; i++) { ll c,k,d; cin >> c >> k >> d; c--,d--; ans-=a[c]*a[c]; a[c]-=k; ans+=a[c]*a[c]; ans-=a[d]*a[d]; a[d]+=k; ans+=a[d]*a[d]; cout << ans << endl; } }