#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> var;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    var.push_back(a);
  }
  int q;
  cin >> q;
  while (q) {
    int b, c;
    cin >> b >> c;
    auto it = find(var.begin(), var.end(), b);
    var.insert(it, c);
    long long int sum = accumulate(var.begin(), var.end(), 0);
    cout << sum;
    q--;
  }
}
