#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q, b, c, i, a;
  cin >> n;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> b >> c;
    replace(v.begin(), v.end(), b, c);
    cout << accumulate(v.begin(), v.end(), 0) << endl;
  }
  return 0;
}
