#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long n, i = 0;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  long q;
  cin >> q;
  int b[q], c[q];
  for (i = 0; i < q; i++) {
    cin >> b[i] >> c[i];
    replace(a, a + n, b[i], c[i]);
    cout << accumulate(a, a + n, 0) << endl;
  }
}
