#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> s;
  int sum{0};
  for (int i{0}; i < n; i++) {
    int a;
    cin >> a;
    s.insert(a);
    sum = sum + a;
  }
  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    sum = sum + c * (s.count(b)) - b * (s.count(b));
    cout << sum << endl;
  }
}
