#include <bits/stdc++.h>
using namespace std;
int sum[400002];
int num[100002];
void buildSegmentTree(int at, int L, int R) {
  sum[at] = 0;
  if (L == R) {
    sum[at] = num[L];
    return;
  }
  int mid = (L + R) / 2;
  buildSegmentTree(at * 2, L, mid);
  buildSegmentTree(at * 2 + 1, mid + 1, R);
  sum[at] = sum[at * 2] + sum[at * 2 + 1];
}
void updateSegemntTreeWithNew(int at, int L, int R, int value1, int value2) {
  if (L == R) {
    if (sum[at] == value1) sum[at] = value2;
    return;
  }
  int mid = (L + R) / 2;
  updateSegemntTreeWithNew(at * 2, L, mid, value1, value2);
  updateSegemntTreeWithNew(at * 2 + 1, mid + 1, R, value1, value2);
  sum[at] = sum[at * 2] + sum[at * 2 + 1];
}
int querySegmentTree(int at, int L, int R, int l, int r) {
  if (r < L || R < l) return 0;
  if (l <= L && R <= r) return sum[at];
  int mid = (L + R) / 2;
  int x = querySegmentTree(at * 2, L, mid, l, r);
  int y = querySegmentTree(at * 2 + 1, mid + 1, R, l, r);
  return x + y;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
  }
  buildSegmentTree(1, 1, n);
  int q, x, y;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &x, &y);
    updateSegemntTreeWithNew(1, 1, n, x, y);
    printf("%d\n", querySegmentTree(1, 1, n, 1, n));
  }
  return 0;
}
