#include <bits/stdc++.h>
using namespace std;
vector<long long> v1;
vector<long long>::iterator upper, lower, it;
vector<vector<long long>> adj(200005);
void solve() {
  long long n = 0, m = 0, i = 0, j = 0, l = 0, r = 0, x = 0, y = 0, q = 0,
            z = 0, len = 0, k = 0, p = 0;
  long long a[300005] = {0}, b[300005] = {0}, c[200005] = {0}, d[200005] = {0};
  char s[300005], t[300005];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  b[0] = a[0];
  for (i = 1; i < n; i++) {
    b[i] += b[i - 1] + a[i];
  }
  cin >> q;
  while (q--) {
    cin >> x;
    long long sum = 0;
    if (x != 1) {
      sum += b[x - 2];
    }
    sum += (b[n - 1] - b[x - 1]);
    cout << sum << "\n";
  }
}
bool imp = false;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  if (imp) cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
