#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n;
  vector<int> A(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    sum += A[i];
  }
  cin >> q;
  int b, c;
  for (int ii = 0; ii < q; ii++) {
    cin >> b >> c;
    for (int i = 0; i < n; i++) {
      if (b == A[i]) {
        sum -= A[i] - c;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
