#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int n, m;
  cin >> n;
  unsigned long long int a[n];
  for (unsigned long long int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n, std::greater<unsigned long long int>());
  cin >> m;
  unsigned long long int q;
  unsigned long long int s[n];
  s[0] = a[0];
  for (unsigned long long int i = 1; i < n; ++i) s[i] = a[i] + s[i - 1];
  for (unsigned long long int i = 0; i < m; ++i) {
    cin >> q;
    unsigned long long int r = 0;
    r += s[q - 2];
    r += s[n - 1] - s[q - 2] - a[q - 1];
    cout << r << "\n";
  }
  return 0;
}
