#include <bits/stdc++.h>
using namespace std;
const string FILENAME = "";
const bool FILE_IO = 1;
const int INF = 1000000000;
void init() {
  if (!FILENAME.empty()) {
    freopen((FILENAME + ".in").c_str(), "r", stdin);
    freopen((FILENAME + ".out").c_str(), "w", stdout);
  }
}
int main() {
  init();
  int n, m;
  cin >> n;
  vector<int> arr(n);
  vector<long long> s(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cin >> m;
  sort(arr.begin(), arr.end());
  reverse(arr.begin(), arr.end());
  s[0] = arr[0];
  for (int i = 1; i < n; i++) {
    s[i] += arr[i] + s[i - 1];
  }
  for (int i = 0; i < m; i++) {
    int q;
    long long ans = 0;
    cin >> q;
    ans = s[q - 2] + s[n - 1] - s[q - 1];
    cout << ans << endl;
  }
  return 0;
}
