#include <bits/stdc++.h>
using namespace std;
int occur(int arr[], int n, int b) {
  int count = 0;
  for (int i = 0; i < n; ++i) {
    if (arr[i] == b) count++;
  }
  return count;
}
int main() {
  int n, t, i, q, b, c;
  cin >> n;
  int a[n + 1];
  long long int sum = 0, ans;
  for (i = 0; i < n; i++) cin >> a[i];
  cin >> q;
  for (i = 0; i < n; i++) sum += a[i];
  for (i = 0; i < q; ++i) {
    t = 0, ans = 0;
    cin >> b >> c;
    t = occur(a, n, b);
    ans = sum - t * (b - c);
    cout << ans << endl;
  }
  return 0;
}
