#include <bits/stdc++.h>
using namespace std;
using namespace std;
void heapify(int arr[], int n, int i) {
  int largest = i;
  int l = 2 * i + 1;
  int r = 2 * i + 2;
  if (l < n && arr[l] > arr[largest]) largest = l;
  if (r < n && arr[r] > arr[largest]) largest = r;
  if (largest != i) {
    swap(arr[i], arr[largest]);
    heapify(arr, n, largest);
  }
}
void heapSort(int arr[], int n) {
  for (int i = n / 2 - 1; i >= 0; i--) heapify(arr, n, i);
  for (int i = n - 1; i >= 0; i--) {
    swap(arr[0], arr[i]);
    heapify(arr, i, 0);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  unsigned long long tong = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    tong += a[i];
  }
  heapSort(a, n);
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int h;
    cin >> h;
    tong -= a[n - h];
    cout << tong << endl;
    tong += a[n - h];
  }
  return 0;
}
