#include <bits/stdc++.h>
using namespace std;
void outi(int x) { cout << x << endl; }
void outl(long long x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
long long max(long long a, long long b) {
  long long max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
long long min(long long a, long long b) {
  long long min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  int q;
  cin >> q;
  vector<int> p(q);
  vector<int> w(q);
  for (int i = 0; i < (q); ++i) {
    cin >> p[i] >> w[i];
  }
  for (int j = 0; j < (q); ++j) {
    long long ans = 0;
    for (int i = 0; i < (n); ++i) {
      if (a[i] == p[j]) {
        a[i] = w[j];
      }
      ans += a[i];
    }
    cout << ans << endl;
  }
}
