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