#include <bits/stdc++.h>
using namespace std;
const int N = -1;
vector<long long> v, ac;
long long fsoma(int l, int r) {
  if (l > r) return 0;
  return ac[r + 1] - ac[l];
}
int main() {
  int n;
  cin >> n;
  long long x;
  for (int i = 0; i < n; i++) scanf("%lld", &x), v.emplace_back(x);
  sort((v).begin(), (v).end());
  reverse((v).begin(), (v).end());
  ac.resize(n + 1);
  for (int i = 0; i < n; i++) {
    ac[i + 1] = ac[i] + v[i];
  }
  int q;
  cin >> q;
  for (int qq = 0; qq < q; qq++) {
    int id;
    scanf("%d", &id);
    printf("%lld\n", fsoma(0, id - 2) + fsoma(id, n - 1));
  }
  return 0;
}
