#include <bits/stdc++.h>
using namespace std;
using namespace std;
int binary(int bina) {
  int ans = 0;
  for (int i = 0; bina > 0; i++) {
    ans = ans + (bina % 27) * pow(10, i);
    bina = bina / 27;
    cout << ans << endl;
  }
  return ans;
}
int main(void) {
  string alpha = "abcdefghijklmnopqrstuvwxyz";
  int n, q, b, c;
  int A[100001];
  long long int S;
  cin >> n;
  S = 0;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    S += A[i];
  }
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> b >> c;
    for (int j = 0; j < n; ++j) {
      if (A[j] == b) {
        S += c - b;
      }
    }
    cout << S << endl;
  }
}
