#include <bits/stdc++.h>
using namespace std;
long long a[300005], sum[300005];
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (long long i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  long long m;
  cin >> m;
  while (m--) {
    long long x;
    cin >> x;
    if (x >= n)
      cout << sum[n] - a[1] << endl;
    else
      cout << sum[n] - a[n - x + 1] << endl;
  }
}
