#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int main() {
  int N;
  cin >> N;
  vector<int> vec_A;
  for (int i = 0; i < (N); i++) {
    int tmp;
    cin >> tmp;
    vec_A.push_back(tmp);
  }
  int Q;
  cin >> Q;
  vector<pair<int, int>> vec_p;
  for (int i = 0; i < (Q); i++) {
    int tmp_b, tmp_c;
    cin >> tmp_b >> tmp_c;
    pair<int, int> tmp_p = {tmp_b, tmp_c};
    vec_p.push_back(tmp_p);
  }
  for (int i = 0; i < (Q); i++) {
    int key = vec_p[i].first;
    int value = vec_p[i].second;
    auto low = lower_bound(vec_A.begin(), vec_A.end(), key);
    auto high = upper_bound(vec_A.begin(), vec_A.end(), key);
    int itr_l = low - vec_A.begin();
    int itr_h = high - vec_A.begin();
    if (low != vec_A.end()) {
      for (int j = 0; j < (itr_h - itr_l); j++) {
        int itr = low - vec_A.begin();
        vec_A[itr + j] = value;
      }
    }
    int sum = accumulate(vec_A.begin(), vec_A.end(), 0);
    cout << sum << endl;
  }
  return 0;
}
