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