#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n, sum;
  cin >> n;
  long long int a[n];
  std::vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int t;
  cin >> t;
  long long int a1, b;
  while (t--) {
    sum = 0;
    cin >> a1 >> b;
    replace(a, a + n, a1, b);
    for (long long int i = 0; i < n; i++) {
      sum += a[i];
    }
    cout << sum << endl;
  }
}
