#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sum = 0;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q - 1; i++) {
    int index, element;
    cin >> index >> element;
    sum -= a[index - 1];
    a[index - 1] = element;
    sum += element;
    cout << sum << endl;
  }
  int index1, index2;
  cin >> index1 >> index2;
  int z = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == index1) z++;
  }
  sum -= index1 * z;
  sum += index2 * z;
  cout << sum << endl;
  return 0;
}
