#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  vector<long long> v;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long t;
    cin >> t;
    v.emplace_back(t);
  }
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long b, c;
    long long s = 0;
    cin >> b >> c;
    replace(v.begin(), v.end(), b, c);
    for (long long k = 0; k < n; k++) {
      s += v[k];
    }
    cout << s << endl;
  }
}
