#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MX = 1e18;
const long double PI = acos(-1);
int main() {
  int n, q;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  cin >> q;
  ll ans = 0;
  for (int i = 0; i < (q); ++i) {
    int b, c;
    cin >> b >> c;
    replace(a.begin(), a.end(), b, c);
    ans = accumulate(a.begin(), a.end(), 0);
    cout << ans << endl;
  }
  return 0;
}
