#include <bits/stdc++.h>
using namespace std;
int cmp(const void *a, const void *b) { return *(int *)b - *(int *)a; }
const int SIZE = 3e5;
int n, m, a[SIZE], q[SIZE];
long long s = 0;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  qsort(a, n, sizeof a[0], cmp);
  for (int i = 0; i < n; i++) s += a[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> q[i];
    cout << s - a[q[i] - 1] << endl;
  }
  return 0;
}
