#include <bits/stdc++.h>
using namespace std;
template <class T, size_t N>
size_t sza(const T (&array)[N]) {
  return N;
}
template <class T>
inline void chmax(T &a, const T &b) {
  if (a < b) a = b;
}
template <class T>
inline void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T = long long>
T in() {
  T x;
  cin >> x;
  return (x);
}
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
long long dx[] = {1, -1, 0, 0};
long long dy[] = {0, 0, 1, -1};
long long solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = (long long)(0); i < (long long)(n); ++i) {
    cin >> a[i];
  }
  long long m;
  cin >> m;
  sort(a, a + n);
  long long s = accumulate(a, a + n, 0LL);
  for (long long i = (long long)(0); i < (long long)(m); ++i) {
    long long q;
    cin >> q;
    cout << s - a[n - q] << endl;
  }
  return 0;
}
signed main() {
  solve();
  return 0;
}
