#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T x, T y) {
  T mod;
  while (x % y) {
    mod = x % y;
    x = y;
    y = mod;
  }
  return y;
}
int kdx[] = {2, 2, -2, -2, 1, -1, 1, -1};
int kdy[] = {1, -1, 1, -1, 2, 2, -2, -2};
int edx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int edy[] = {0, 0, 1, -1, 1, -1, 1, -1};
int fdx[] = {1, -1, 0, 0};
int fdy[] = {0, 0, 1, -1};
vector<long long> s;
int main() {
  int n;
  scanf("%d", &n);
  long long k;
  s.push_back(0);
  while (n--) {
    scanf("%lld", &k);
    s.push_back(k);
  }
  scanf("%d", &n);
  sort(s.begin(), s.end());
  for (int i = 1; i < s.size(); i++) {
    s[i] += s[i - 1];
  }
  int sz = s.size() - 1;
  while (n--) {
    scanf("%d", &k);
    int t = (sz - k) + 1;
    long long ans = s[s.size() - 1] - s[t];
    ans += s[t - 1];
    printf("%lld", ans);
    printf("\n");
  }
  return 0;
}
