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