#include <bits/stdc++.h>
using namespace std;
int count(vector<int> A, int target) {
  int result = 0;
  for (int i : A) {
    if (i > target) {
      return result;
    }
    if (i == target) {
      result++;
    }
  }
  return result;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int Q;
  cin >> Q;
  int result = accumulate(A.begin(), A.end(), 0);
  for (int i = 0; i < Q; i++) {
    int B, C;
    cin >> B >> C;
    int tmp = count(A, B);
    result = result - (B - C) * tmp;
    cout << result << endl;
  }
}
