#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  long long int dp[n], ford[n];
  long long int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> m;
  sort(a, a + n);
  dp[n - 1] = a[n - 1];
  ford[0] = a[0];
  int lim = n - 2;
  for (int j = lim; j >= 0; j--) {
    dp[j] = dp[j + 1] + a[j];
  }
  for (int i = 1; i < n; i++) {
    ford[i] = ford[i - 1] + a[i];
  }
  for (int i = 0; i < m; i++) {
    int q;
    cin >> q;
    if (q == n) {
      cout << dp[1] << endl;
      continue;
    }
    cout << ford[n - q - 1] + dp[n - q + 1] << endl;
  }
}
