#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, i, b, c, x, ctr = 0;
  cin >> n;
  vector<int> a;
  vector<long long> sum;
  for (i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> b >> c;
    x = *find(a.begin(), a.end(), b);
    if (x != (*a.end() - 1)) {
      a[x] = c;
    }
    sum.push_back(accumulate(a.begin(), a.end(), 0));
  }
  for (i = 0; i < sum.size(); i++) {
    cout << sum[i];
  }
  return 0;
}
