#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<int> a;
  int tmp;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  int Q;
  int b, c;
  cin >> Q;
  vector<long long int> sum;
  long long int tmp1;
  for (int i = 0; i < Q; i++) {
    cin >> b >> c;
    replace(a.begin(), a.end(), b, c);
    tmp1 = accumulate(a.begin(), a.end(), 0);
    sum.push_back(tmp1);
  }
  for (int i = 0; i < Q; i++) {
    cout << sum[i] << endl;
  }
}
