#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n], sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  long long q;
  cin >> q;
  while (q--) {
    long long bi, ci;
    cin >> bi >> ci;
    long long x = upper_bound(a, a + n, bi) - lower_bound(a, a + n, bi);
    cout << (sum - (bi * x)) + (ci * x) << endl;
  }
  return 0;
}
