#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long a[N], q[N];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
  }
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x;
    cin >> x;
    cout << (a[n] - a[x] + a[x - 1]) << "\n";
  }
  return 0;
}
