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