#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 3e5 + 15;
long long n, sum;
long long Arr[MAX_N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> Arr[i];
    sum += Arr[i];
  }
  sort(Arr, Arr + n);
  long long q;
  cin >> q;
  while (q--) {
    long long tmp;
    cin >> tmp;
    cout << sum - Arr[n - tmp] << "\n";
  }
  return 0;
}
