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