#include <bits/stdc++.h>
using namespace std;
void build(vector<long long> arr, vector<long long> &segmentTree, long long low,
           long long high, long long pos) {
  if (low == high) {
    segmentTree[pos] = arr[low];
  } else {
    long long mid = (low + high) / 2;
    build(arr, segmentTree, low, mid, 2 * pos + 1);
    build(arr, segmentTree, mid + 1, high, 2 * pos + 2);
    segmentTree[pos] = segmentTree[2 * pos + 1] + segmentTree[2 * pos + 2];
  }
}
void update(vector<long long> &segmentTree, long long a, long long b,
            long long low, long long high, long long pos) {
  if (low == high) {
    if (segmentTree[pos] == a) segmentTree[pos] = b;
  } else {
    long long mid = (low + high) / 2;
    update(segmentTree, a, b, low, mid, 2 * pos + 1);
    update(segmentTree, a, b, mid + 1, high, 2 * pos + 2);
    segmentTree[pos] = segmentTree[2 * pos + 1] + segmentTree[2 * pos + 2];
  }
}
int main() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (long long i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  long long height = 2 * pow(2, ceil(log2(n))) - 1;
  vector<long long> st(height);
  build(arr, st, 0, n - 1, 0);
  long long q;
  cin >> q;
  for (long long i = 0; i < q; ++i) {
    long long a, b;
    cin >> a >> b;
    update(st, a, b, 0, n - 1, 0);
    cout << st[0] << endl;
  }
  return 0;
}
