#include <bits/stdc++.h>
using namespace std;
void countFreq(int arr[], int n) {
  unordered_map<int, int> mp;
  for (int i = 0; i < n; i++) mp[arr[i]]++;
  for (int i = 0; i < n; i++) {
    if (mp[arr[i]] != -1) {
      cout << arr[i] << " " << mp[arr[i]] << endl;
      mp[arr[i]] = -1;
    }
  }
}
int main() {
  int n, s = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
  }
  int m;
  cin >> m;
  while (m--) {
    int j, k, d = 0;
    cin >> j >> k;
    d = s;
    int o = count(a, a + n, j);
    d = d + o * (k - j);
    cout << d << endl;
  }
  return 0;
}
