#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int num;
  cin >> num;
  vector<int> array;
  for (int i = 0; i < num; i++) {
    int tmp;
    cin >> tmp;
    array.push_back(tmp);
  }
  int CNT;
  cin >> CNT;
  for (int i = 0; i < CNT; i++) {
    int b, c;
    cin >> b >> c;
    replace(array.begin(), array.end(), b, c);
    int sum = 0;
    for (int j = 0; j < num; j++) {
      sum += array[j];
    }
    cout << sum << '\n';
  }
  return 0;
}
