#include <bits/stdc++.h>
using namespace std;
long long getMid(int s, int e) { return s + (e - s) / 2; }
long long getSumUtil(long long* st, long long ss, long long se, long long qs,
                     long long qe, long long si) {
  if (qs <= ss && qe >= se) return st[si];
  if (se < qs || ss > qe) return 0;
  long long mid = getMid(ss, se);
  return getSumUtil(st, ss, mid, qs, qe, 2 * si + 1) +
         getSumUtil(st, mid + 1, se, qs, qe, 2 * si + 2);
}
void updateValueUtil(long long* st, long long ss, long long se, long long i,
                     long long diff, long long si) {
  if (i < ss || i > se) return;
  st[si] = st[si] + diff;
  if (se != ss) {
    long long mid = getMid(ss, se);
    updateValueUtil(st, ss, mid, i, diff, 2 * si + 1);
    updateValueUtil(st, mid + 1, se, i, diff, 2 * si + 2);
  }
}
void updateValue(vector<long long>& arr, long long* st, long long n,
                 long long i, long long new_val) {
  if (i < 0 || i > n - 1) {
    cout << "Invalid Input";
    return;
  }
  long long diff = new_val - arr[i];
  arr[i] = new_val;
  updateValueUtil(st, 0, n - 1, i, diff, 0);
}
long long getSum(long long* st, long long n, long long qs, long long qe) {
  if (qs < 0 || qe > n - 1 || qs > qe) {
    cout << "Invalid Input";
    return -1;
  }
  return getSumUtil(st, 0, n - 1, qs, qe, 0);
}
long long constructSTUtil(vector<long long>& arr, long long ss, long long se,
                          long long* st, long long si) {
  if (ss == se) {
    st[si] = arr[ss];
    return arr[ss];
  }
  int mid = getMid(ss, se);
  st[si] = constructSTUtil(arr, ss, mid, st, si * 2 + 1) +
           constructSTUtil(arr, mid + 1, se, st, si * 2 + 2);
  return st[si];
}
long long* constructST(vector<long long>& arr, long long n) {
  long long x = (long long)(ceil(log2(n)));
  long long max_size = 2 * (long long)pow(2, x) - 1;
  long long* st = new long long[max_size];
  constructSTUtil(arr, 0, n - 1, st, 0);
  return st;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n;
  vector<long long> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long* st = constructST(a, n);
  cin >> q;
  long long b, c;
  while (q--) {
    cin >> b >> c;
    for (int i = 0; i < n; i++) {
      if (a[i] == b) {
        updateValue(a, st, n, i, c);
      }
    }
    cout << getSum(st, n, 0, n - 1) << endl;
  }
  return 0;
}
