## Algorithm

B. Discounts
time limit per test
2.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You came to a local shop and want to buy some chocolate bars. There are n

bars in the shop, i-th of them costs ai

coins (and you want to buy all of them).

You have m

different coupons that allow you to buy chocolate bars. i-th coupon allows you to buy qi chocolate bars while you have to pay only for the qi1 most expensive ones (so, the cheapest bar of those qi

You can use only one coupon; if you use coupon i

, you have to choose qi bars and buy them using the coupon, and buy all the remaining nqi

bars without any discounts.

To decide which coupon to choose, you want to know what will be the minimum total amount of money you have to pay if you use one of the coupons optimally.

Input

The first line contains one integer n

(2n3105

) — the number of chocolate bars in the shop.

The second line contains n

integers a1, a2, ..., an (1ai109), where ai is the cost of i

-th chocolate bar.

The third line contains one integer m

(1mn1

) — the number of coupons you have.

The fourth line contains m

integers q1, q2, ..., qm (2qin), where qi is the number of chocolate bars you have to buy using i-th coupon so that the least expensive of them will be for free. All values of qi

are pairwise distinct.

Output

Print m

integers, i-th of them should be the minimum amount of money you have to pay if you buy qi bars with i

-th coupon, and all the remaining bars one by one for their full price.

Example
Input
Copy
7
7 1 3 1 4 10 8
2
3 4

Output
Copy
27
30

Note

Consider the first example.

If we use the first coupon, we may choose chocolate bars having indices 1

, 6 and 7, and we pay 18 coins for them and 9

coins for all other bars.

If we use the second coupon, we may choose chocolate bars having indices 1

, 5, 6 and 7, and we pay 25 coins for them and 5 coins for all other bars.

## Code Examples

### #1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int n;
cin>>n;
int arr[n];
long long sum = 0;
for(int i = 0; i  <  n; i++){
cin>>arr[i];
sum += arr[i];
}

sort(arr, arr+n, greater < int>());

int m;
cin>>m;
int q;
for(int i = 0; i  <  m; i++){
cin>>q;
cout<<(sum - arr[q - 1])<<'\n';
}

}
Copy The Code &

Input

cmd
7
7 1 3 1 4 10 8
2
3 4

Output

cmd
27
30