#include <bits/stdc++.h>
using namespace std;
long long sum = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, t;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long q;
  cin >> q;
  while (q--) {
    long long b, c, sum1 = 0;
    cin >> b >> c;
    replace(a, a + n, b, c);
    for (long long i = 0; i < n; i++) {
      sum1 += a[i];
    }
    cout << sum1 << "\n";
  }
  return 0;
}
