#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long N;
  cin >> N;
  long A[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  long Q;
  cin >> Q;
  long num[100001] = {0};
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    num[A[i]] = num[A[i]] + A[i];
    ans = ans + A[i];
  }
  long B[Q], C[Q];
  for (int i = 0; i < Q; ++i) {
    cin >> B[i] >> C[i];
  }
  for (int i = 0; i < Q; ++i) {
    ans = ans - num[B[i]] + (C[i] * num[B[i]] / B[i]);
    cout << ans << "\n";
  }
}
