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