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