#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  int q;
  cin >> q;
  vector<p> rpc(q);
  for (int i = 0; i < (q); i++) cin >> rpc[i].first >> rpc[i].second;
  ll s = 0;
  for (int i = 0; i < (n); i++) s += a[i];
  for (int i = 0; i < (q); i++) {
    for (int j = 0; j < (n); j++) {
      if (a[j] == rpc[i].first) {
        s += rpc[i].second - a[j];
        a[j] = rpc[i].second;
      }
    }
    cout << s << endl;
  }
  return 0;
}
