#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T lowbit(T x) {
  return x & (-x);
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
inline T Pow(T a, T b, T p) {
  T ret = 1;
  a %= p;
  for (; b; b >>= 1, a = a * a % p)
    if (b & 1) (ret *= a) %= p;
  return ret;
}
template <class T>
inline void read(T &ret) {
  T x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  ret = x * f;
}
const int N = 3e5 + 10;
long long a[N], n, m, q[N];
int main() {
  read(n);
  long long tot = 0;
  for (int i = (1); i <= (n); i++) read(a[i]), tot += a[i];
  read(m);
  for (int i = (1); i <= (m); i++) read(q[i]);
  sort(a + 1, a + n + 1);
  for (int i = (1); i <= (m); i++) printf("%lld\n", tot - a[n - q[i] + 1]);
}
