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