#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
template <class T>
T Sum(vector<T> t) {
  T sum = 0;
  for (int i = 0; i < t.size(); i++) {
    sum += t[i];
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int q;
  cin >> q;
  vector<long long int> b(q);
  vector<long long int> c(q);
  for (int i = 0; i < q; i++) {
    cin >> b[i] >> c[i];
  }
  for (int i = 0; i < q; i++) {
    replace(a.begin(), b.end(), b[i], c[i]);
    cout << Sum<long long int>(a) << endl;
  }
}
