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 $a_i$ 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 $q_i$ chocolate bars while you have to pay only for the $q_i - 1$ most expensive ones (so, the cheapest bar of those $q_i$ bars is for free).

You can use only one coupon; if you use coupon $i$, you have to choose $q_i$ bars and buy them using the coupon, and buy all the remaining $n - q_i$ 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$ ($2 \le n \le 3 \cdot 10^5$) — the number of chocolate bars in the shop.

The second line contains $n$ integers $a_1$, $a_2$, ..., $a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is the cost of $i$-th chocolate bar.

The third line contains one integer $m$ ($1 \le m \le n - 1$) — the number of coupons you have.

The fourth line contains $m$ integers $q_1$, $q_2$, ..., $q_m$ ($2 \le q_i \le n$), where $q_i$ 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 $q_i$ 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 $q_i$ bars with $i$-th coupon, and all the remaining bars one by one for their full price.


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

Output
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.

Difficulty: EASY
Tags: Sorting

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
n = int(input())
prices = [int(i) for i in input().split(' ')]
m = int(input())
coupons = [int(i) for i in input().split(' ')]
total_sum = sum(prices)
ordered_p = sorted(prices)
for coupon in coupons:
	print(total_sum - ordered_p[-coupon])


n = int(input())
choks = sorted(list(map(int, input().split())), reverse=True)
m = int(input())
tickets = list(map(int, input().split()))
arsum = sum(choks)
for request in tickets:
	print(arsum - choks[request - 1])


n = int(input())
lst = list(map(int, input().split()))
c = int(input())
clst = list(map(lambda x: int(x) - 1, input().split()))
lst = sorted(lst, key=lambda x: x, reverse=True)
sleft = [0 for _ in range(n)]
sright = [0 for _ in range(n)]
cnt = 0
for i in range(n):
	cnt += lst[i]
	sright[i] = cnt
for i in range(n):
	cnt -= lst[i]
	sleft[i] = cnt
for coupon in clst:
	print(sright[coupon] - lst[coupon] + sleft[coupon])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort(reverse=True)
price = sum(a)
for elem in q:
	cur = price - a[elem - 1]
	print(cur)


n = int(input())
ar = list(map(int, input().split()))
k = int(input())
ar.sort(reverse=True)
s = sum(ar)
x = list(map(int, input().split()))
for i in x:
	s -= ar[i - 1]
	print(s)
	s += ar[i - 1]


a = int(input())
b = [int(i) for i in input().split()]
c = int(input())
d = [int(i) for i in input().split()]
b.sort(reverse=True)
sum = 0
for k in range(a):
	sum += b[k]
for j in d:
	print(sum - b[j - 1])


n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
s = sum(a)
m = int(input())
b = list(map(int, input().split()))
for i in range(m):
	print(s - a[b[i] - 1])


def solve():
	_ = int(input())
	a = list(map(int, input().split()))
	a.sort()
	_ = int(input())
	qq = list(map(int, input().split()))
	res = sum(a)
	for q in qq:
		print(res - a[-q])
solve()


n = int(input())
a = list(map(int, input().split()))
a.sort()
c = sum(a)
m = int(input())
q = list(map(int, input().split()))
res = list()
for i in range(m):
	print(c - a[n - q[i]], end='\n')


R = lambda : map(int, input().split())
n = int(input())
L = sorted(R(), reverse=True)
s = sum(L)
m = int(input())
res = []
for i in list(R()):
	res.append(str(s - L[i - 1]))
print('\n'.join(res))


from sys import stdin, stdout
(n, a, m, b) = (int(stdin.readline()), sorted(list(map(int, stdin.readline().split())), reverse=True), int(stdin.readline()), list(map(int, stdin.readline().split())))
s = sum(a)
for i in range(m):
	print(s - a[b[i] - 1])


n = int(input())
x = list(map(int, input().split()))
m = int(input())
y = list(map(int, input().split()))
r = []
t = sum(x)
x.sort()
x.reverse()
for i in y:
	print(t - x[i - 1])


n = int(input())
lst = list(map(int, input().split()))
sume = sum(lst)
lst.sort()
m = input()
lst1 = list(map(int, input().split()))
for i in lst1:
	print(sume - lst[n - i])


n = int(input())
l = list(map(int, input().split()))
m = int(input())
d = list(map(int, input().split()))
g = sum(l)
l.sort()
for i in d:
	print(g - l[-i])


import sys

class BDiscounts:

	def solve(self):
		n = int(input())
		a = [int(_) for _ in input().split()]
		m = int(input())
		q = [int(_) for _ in input().split()]
		s = sum(a)
		a.sort(reverse=True)
		for i in range(m):
			print(s - a[q[i] - 1])
solver = BDiscounts()
input = sys.stdin.readline
solver.solve()


num_chocolates = int(input())
precos = input().split()
precos = [int(i) for i in precos]
precos.sort()
soma = sum(precos)
num_cupom = int(input())
cupons = input().split()
cupons = [int(i) for i in cupons]
for i in range(num_cupom):
	exclusao = num_chocolates - cupons[i]
	excluido = precos[exclusao]
	print(soma - excluido)


totalbars = int(input())
bars = input().split()
total = 0
for i in range(totalbars):
	bars[i] = int(bars[i])
	total += bars[i]
bars = [int(x) for x in bars]
totalcups = int(input())
coups = input().split()
coups = [int(x) for x in coups]
bars.sort()
totalLoop = total
for i in range(totalcups):
	totalLoop -= bars[totalbars - coups[i]]
	print(totalLoop)
	totalLoop = total


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
s = sum(a)
m = int(input())
b = list(map(int, input().split()))
for bi in b:
	print(s - a[bi - 1])


def ans(arr, q):
	return sum_ - arr[q - 1]
n = int(input())
a = list(map(int, input().strip().split()))
m = int(input())
q = list(map(int, input().strip().split()))
sum_ = sum(a)
a.sort(reverse=True)
for i in range(m):
	print(ans(a, q[i]))


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
s = sum(l)
m = int(input())
a = list(map(int, input().split()))
for i in a:
	print(s - l[i - 1])


import os
import sys
import math
import collections
import cmath

def mp():
	return map(int, input().split())

def inp():
	return input()
n = int(inp())
ar = list(mp())
s = sum(ar)
ar.sort(reverse=True)
m = int(inp())
d = list(mp())
for i in d:
	print(s - ar[i - 1])


_ = input()
total = 0
prices = []
for price in input().split():
	price = int(price)
	total += price
	prices.append(price)
prices.sort(reverse=True)
_ = input()
for coupon in input().split():
	print(str(total - prices[int(coupon) - 1]))


q = lambda : map(int, input().split())
q()
a = sorted(list(q()))
q()
d = sum(a)
[print(d - a[-_]) for _ in q()]


i = lambda : [*map(int, input().split())]
i()
a = sorted(i(), reverse=1)
s = sum(a)
i()
print(*[s - a[x - 1] for x in i()], sep='\n')


n = int(input())
a = [int(e) for e in input().split()]
q = int(input())
b = [int(e) for e in input().split()]
s = sum(a)
a.sort()
for i in b:
	print(s - a[n - i])


x = int(input())
l = list(map(int, input().split()))
l.sort()
su = 0
for j in range(len(l)):
	su += l[j]
m = int(input())
m1 = list(map(int, input().split()))
for i in range(m):
	q = m1[i]
	ans = su - l[-q]
	print(ans)


bars = int(input())
costs = [int(x) for x in input().strip().split(' ')]
nCoupons = int(input())
coupons = [int(x) for x in input().strip().split(' ')]
costs.sort(reverse=True)
for i in range(1, bars):
	costs[i] += costs[i - 1]
for i in coupons:
	coins = costs[bars - 1] - (costs[i - 1] - costs[i - 2])
	print(coins)


import math
l1 = input()
l2 = input().split()
l3 = int(input())
l4 = input().split()
l2 = [int(i) for i in l2]
l4 = [int(i) for i in l4]
l2.sort(reverse=True)
soma = sum(l2)
for i in range(l3):
	print(soma - l2[l4[i] - 1])


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
total = sum(a)
input()
m = list(map(int, input().split()))
for q in m:
	print(total - a[q - 1])


def binSer(string, x):
	mid = len(string) // 2
	if string[mid] == x:
		return 1
	if ord(string[mid]) < ord(x):
		for i in string[mid + 1:]:
			if i == x:
				return 1
		return -1
	if ord(string[mid]) > ord(x):
		for i in string[:mid]:
			if i == x:
				return 1
		return -1

def solve():
	n = int(input())
	array = [int(i) for i in input().split()]
	array.sort(reverse=True)
	m = int(input())
	sum = 0
	arr = [int(i) for i in input().split()]
	for j in array:
		sum += j
	for i in range(m):
		print(sum - array[arr[i] - 1])
solve()


I = lambda : map(int, input().split())
(n,) = I()
s = sorted(I())
m = int(input())
k = sum(s)
print(*[k - s[-i] for i in I()])


a = int(input())
b = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
b.sort()
s = sum(b)
prev = 0
for j in q:
	print(s - b[-j] + prev)


n = int(input())
prices = list(map(int, input().split()))
coupons = int(input())
count_of_ch = list(map(int, input().split()))
prices.sort()
summ = sum(prices)
for count in count_of_ch:
	print(summ - prices[-count])


n = int(input())
precos = input()
precos = list(map(int, precos.split()))
precos = sorted(precos, reverse=True)
m = int(input())
discontos = input()
discontos = list(map(int, discontos.split()))
soma = 0
for i in range(n):
	soma += precos[i]
for s in range(m):
	print(soma - precos[discontos[s] - 1])


alph = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
E = sum(a)
m = int(input())
q = list(map(int, input().split()))
for i in range(m):
	print(E - a[q[i] - 1])


n = int(input())
price = sorted([int(x) for x in input().split()])
total_price = sum(price)
no_of_coupons = int(input())
coupons = [int(x) for x in input().split()]
for i in range(no_of_coupons):
	print(total_price - price[-coupons[i]])


import sys, math, operator, itertools, collections, heapq, bisect

class Solution:

	def __init__(self):
		pass

	def solve(self, *Input):
		(a, q) = Input
		a.sort()
		s = sum(a)
		for x in q:
			print(s - a[-x])

	def create(self, *Input):
		(n, colors) = Input
		color_set = set()
		tree = [set()]
		for i in range(1, n + 1):
			color_set.add(colors[i - 1])
			tree.append(color_set - tree[i & i - 1])
		return tree

	def check(self, *Input):
		(k, matrix) = Input
		cnt = 0
		for row in matrix:
			cnt += row.count('#')
		return cnt == k

	def sieve_classic(self, a, b):
		self.primes = [True] * (b + 1)
		self.primes[0] = self.primes[1] = False
		for i in range(2, b + 1):
			if self.primes[i] and i * i <= b:
				for j in range(i * i, b + 1, i):
					self.primes[j] = False
		self.primes = [x for (x, y) in enumerate(self.primes) if y]
		ind = bisect.bisect_left(self.primes, a)
		self.primes[:ind] = []
		return None
solution = Solution()
inputs = iter(sys.stdin.readlines())
n = int(next(inputs))
a = list(map(int, next(inputs).split()))
m = int(next(inputs))
q = list(map(int, next(inputs).split()))
ans = solution.solve(a, q)


n = input()
lis = list(map(int, input().split()))
lis.sort(reverse=True)
input()
sum = sum(lis)
coup = list(map(int, input().split()))
for j in range(len(coup)):
	print(sum - lis[coup[j] - 1])


i = input
n = int(i())
List = [*map(int, i().split())]
m = int(i())
L = [*map(int, i().split())]
List.sort()
Cost = 0
S = sum(List)
for j in range(m):
	print(S - List[n - L[j]])


n = input()
n = int(n)
a = input()
a = a.split()
a = [int(i) for i in a]
m = input()
m = int(m)
q = input()
q = q.split()
q = [int(i) for i in q]
_max = sum(a)
a.sort()
for _ in range(m):
	print(_max - a[-q[_]])


n = int(input())
data = [int(x) for x in input().split()]
q = int(input())
data.sort(reverse=True)
ans = sum(data)
q = [int(x) for x in input().split()]
for i in q:
	print(ans - data[i - 1])


n = int(input())
lista = list(map(int, input().split()))
m = int(input())
cupons = list(map(int, input().split()))
lista.sort()
soma = sum(lista)
for e in cupons:
	print(soma - lista[n - e])


chocotam = int(input())
chocos = [int(x) for x in input().split(' ')]
cupontam = int(input())
cupons = [int(x) for x in input().split(' ')]
chocos.sort()
total = 0
for j in range(chocotam):
	total = total + chocos[j]
for i in range(cupontam):
	number = cupons[i]
	index = chocotam - number
	print(total - chocos[index])


n = int(input())
x = input()
xx = x.split()
for i in range(0, n):
	xx[i] = int(xx[i])
m = int(input())
x = input()
y = x.split()
xx.sort()
s = []
g = 0
for i in xx:
	g += i
p = g
for i in y:
	i = int(i)
	g -= xx[n - i]
	s.append(g)
	g = p
for i in s:
	print(i)


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
a = list(reversed(sorted(a)))
m = int(input())
q = list(map(int, input().split()))
for i in q:
	print(s - a[i - 1])


hm = input()
lis = list(map(int, input().split()))
lis.sort(reverse=True)
hm2 = input()
lis2 = list(map(int, input().split()))
summ = sum(lis)
for i in lis2:
	print(summ - lis[i - 1])


n = int(input())
a = sorted(list(map(int, input().split())))
m = int(input())
q = list(map(int, input().split()))
x = sum(a)
for i in range(m):
	print(x - a[n - q[i]])


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
qrr = list(map(int, input().split()))
arr = sorted(arr)
k = 0
a = sum(arr)
for k in range(m):
	print(a - arr[n - qrr[k]])


a = []
s = 0
n = int(input())
a = list(map(int, input().split(' ')))
a.sort(key=int, reverse=True)
m = int(input())
q = list(map(int, input().split(' ')))
for i in range(1, n):
	a[i] += a[i - 1]
for i in q:
	print(a[i - 2] + a[n - 1] - a[i - 1])


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
a.sort()
s = sum(a)
for i in q:
	print(s - a[-i])


n = int(input())
a = list(map(int, input().split()))
q = int(input())
a.sort()
s = sum(a)
a = [0] + a
p = list(map(int, input().split()))
for i in p:
	print(s - a[-i])


import sys
n = sys.stdin.readline()
arr = [int(i) for i in sys.stdin.readline().split()]
res = sum(arr)
arr.sort(reverse=True)
n = sys.stdin.readline()
p = [int(i) for i in sys.stdin.readline().split()]
for i in p:
	print(res - arr[i - 1])


n = int(input())
a = [int(o) for o in input().split()]
a = sorted(a)
a = a[::-1]
m = int(input())
s = sum(a)
d = [int(o) for o in input().split()]
for i in d:
	print(s - a[i - 1])


n = int(input())
s = 0
a = list(map(int, input().split()))
s = sum(a)
m = int(input())
a.sort(reverse=True)
q = list(map(int, input().split()))
for i in q:
	res = s
	print(res - a[i - 1])


input()
A = sorted((int(x) for x in input().split()))
s = sum(A)
input()
for q in map(int, input().split()):
	print(s - A[-q])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort(reverse=True)
p = sum(a)
for i in range(m):
	print(p - a[q[i] - 1])


n = int(input())
l = [*map(int, input().split())]
m = int(input())
l.sort()
s = sum(l)
for c in map(int, input().split()):
	print(s - l[-c])


n = int(input())
a = sorted(list(map(int, input().split())))
s = sum(a)
m = int(input())
for i in map(int, input().split()):
	print(s - a[-i])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort()
(l, s) = (len(q), sum(a))
for i in range(l):
	print(s - a[n - q[i]])


t = int(input())
a = [int(i) for i in input().split()]
m = int(input())
out = [int(i) for i in input().split()]
a.sort(reverse=True)
ans = 0
s = sum(a)
for i in out:
	ans = s - a[i - 1]
	print(ans)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
Q = list(map(int, input().split()))
a = list(sorted(a, reverse=True))
s = sum(a)
for q in Q:
	print('{}'.format(s - a[q - 1]))


n = int(input())
ns = input().split()
s = 0
for i in range(n):
	ns[i] = int(ns[i])
	s += ns[i]
ns.sort(reverse=True)
m = int(input())
ms = input().split()
for i in range(m):
	print(s - ns[int(ms[i]) - 1])


N = int(input())
arr = list(map(int, input().split()))
arr.sort()
s = sum(arr)
input()
for k in map(int, input().split()):
	print(s - arr[N - k])


i = input().split()
ch = [int(x) for x in input().split()]
ch = sorted(ch)
co = [int(x) for x in input().split()]
cop = [int(x) for x in input().split()]
summ = sum(ch)
for k in cop:
	d = ch[-k]
	print(summ - d)


n = int(input())
a = sorted(list(map(int, input().split())))
r = sum(a)
m = int(input())
b = list(map(int, input().split()))
for i in b:
	print(r - a[-i])


t = int(input())
r = list(map(int, input().split()))
m = int(input())
e = list(map(int, input().split()))
r.sort(reverse=True)
q = sum(r)
for s in range(0, m):
	c = e[s]
	print(q - r[c - 1])


N = int(input())
price = [int(x) for x in input().split()]
M = int(input())
coupans = [int(x) for x in input().split()]
price = sorted(price)
total = 0
for i in price:
	total = total + i
for i in range(M):
	temp = total - price[-coupans[i]]
	print(temp)


n = int(input())
coins = sorted(map(int, input().split()))
total_coins = sum(coins)
m = int(input())
for i in input().split():
	coupon = int(i)
	print(total_coins - coins[-coupon])


n_bars = int(input())
bars = [int(i) for i in input().split()]
n_coupons = int(input())
coupons = [int(i) for i in input().split()]
bars = sorted(bars)[::-1]
bar_sum = sum(bars)
price = [bar_sum - bars[coupon_used - 1] for coupon_used in coupons]
print('\n'.join([str(a) for a in price]))


from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
n = int(input())
l = list(map(int, input().split()))
l.sort()
pref = [0]
for i in l:
	pref.append(pref[-1] + i)
m = int(input())
la = list(map(int, input().split()))
for z in la:
	ans = 0
	print(pref[n - z] + pref[n] - pref[n - z + 1])


bars = int(input())
chocolateBars = list(map(int, input().split()))
coupouns = int(input())
chocolateCoupons = list(map(int, input().split()))
totalCoins = sum(chocolateBars)
chocolateBars.sort(reverse=True)
for i in range(coupouns):
	print(totalCoins - chocolateBars[chocolateCoupons[i] - 1])


n = int(input())
cost = list(map(int, input().split()))
m = int(input())
cc = list(map(int, input().split()))
cost.sort()
s = sum(cost)
for i in cc:
	print(s - cost[n - i])


n = int(input())
a = input().split()
m = int(input())
q = input().split()
total = 0
for i in range(n):
	a[i] = int(a[i])
	total += a[i]
for i in range(m):
	q[i] = int(q[i])
a.sort()
for i in q:
	print(total - a[-i])


n_chocolates = int(input())
array_chocolates = input().split()
array_chocolates = [int(x) for x in array_chocolates]
total_chocolates = sum(array_chocolates)
n_coupons = int(input())
array_coupons = input().split()
array_coupons = [int(x) for x in array_coupons]
array_chocolates = list(reversed(sorted(array_chocolates)))
for discount in array_coupons:
	print(total_chocolates - array_chocolates[discount - 1])


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter
from math import *
from itertools import permutations
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
n = INT()
l = LIST()
l2 = list(reversed(sorted(l)))
m = INT()
c = LIST()
k = sum(l)
for i in range(m):
	z2 = l2[c[i] - 1]
	z3 = k - z2
	print(z3)


n = int(input())
a = []
count = 0
for x in input().split():
	a.append(int(x))
	count += int(x)
m = int(input())
q = [int(x) for x in input().split()]
a.sort()
n = len(a)
for x in q:
	print(count - a[n - x])


a = int(input())
arr = list(map(int, input().split()))
aa = int(input())
brr = list(map(int, input().split()))
arr.sort()
sums = sum(arr)
for i in range(aa):
	print(sums - arr[-brr[i]])


N = int(input())
A = [0] + list(map(int, input().split()))
M = int(input())
Q = list(map(int, input().split()))
A.sort()
for i in range(1, len(A)):
	A[i] = A[i] + A[i - 1]
l = len(A)
for q in Q:
	print(A[l - 1] - A[l - q] + A[l - q - 1])


n = int(input())
price = sorted([int(x) for x in input().split()])
total_price = sum(price)
no_of_coupons = int(input())
for i in map(int, input().split()):
	print(total_price - price[-i])


qtd = int(input())
linha = input().split()
qtd_c = int(input())
s_linha = input().split()
precos = list(map(int, linha))
cupons = list(map(int, s_linha))
lista = sorted(precos, reverse=True)
soma_total = sum(lista)
for i in range(len(cupons)):
	print(soma_total - lista[cupons[i] - 1])


n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
m = int(input())
b = [int(x) for x in input().split()]
money = sum(a)
for i in range(m):
	print(money - a[b[i] - 1])


import sys
import math
import bisect
import itertools

def main():
	n = int(input())
	A = list(map(int, input().split()))
	m = int(input())
	A.sort(reverse=True)
	total = sum(A)
	for q in list(map(int, input().split())):
		print(total - A[q - 1])
main()


n = int(input())
price = list(map(int, input().split()))
price.sort(reverse=True)
m = int(input())
coupon = list(map(int, input().split()))
fullmoney = sum(price)
for i in coupon:
	print(fullmoney - price[i - 1])


n = int(input())
a = sorted(map(int, input().split()))
m = int(input())
b = map(int, input().split())
s = sum(a)
for x in b:
	print(s - a[n - x])


n = int(input())
l = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
l.sort(reverse=True)
s = 0
for i in range(n):
	s += l[i]
for i in range(q):
	print(s - l[m[i] - 1])


n = int(input())
prices = [int(j) for j in input().split()]
m = int(input())
coupons = [int(j) for j in input().split()]
total = sum(prices)
prices.sort()
prices = prices[::-1]
for num in coupons:
	dele = prices[num - 1]
	print(total - dele)


q = int(input())
q = list(map(int, input().split()))
a = int(input())
a = list(map(int, input().split()))
q.sort()
q = q[::-1]
z = sum(q)
for w in a:
	print(z - q[w - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a = sorted(a)[::-1]
c = [0] * n
c[0] = a[0]
st = sum(a)
for i in range(1, n):
	c[i] = c[i - 1] + a[i]
for i in range(m):
	s = c[b[i] - 2]
	s += st - c[b[i] - 1]
	print(s)


barras = int(input())
preco = input().split()
cupons = int(input())
barrasCupons = input().split()
for i in range(len(preco)):
	preco[i] = int(preco[i])
preco.sort(reverse=True)
soma = 0
for e in preco:
	soma += e
for e in barrasCupons:
	x = soma
	x -= preco[int(e) - 1]
	print(x)


import sys
import math
lines = sys.stdin.read().splitlines()
cnt1 = [int(x) for x in lines[0].split(' ')][0]
sweets = [int(x) for x in lines[1].split(' ')]
cnt3 = [int(x) for x in lines[2].split(' ')][0]
coupons = [int(x) for x in lines[3].split(' ')]
sweets = sorted(sweets)
sum = sum(sweets)
for i in coupons:
	if i == 1:
		print(sum)
	else:
		print(sum - sweets[-i])


input()
a = sorted(map(int, input().split()))
s = sum(a)
input()
for i in map(int, input().split()):
	print(s - a[-i])


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
m = int(input())
var = list(map(int, input().split()))
sum = 0
for i in range(n):
	sum += arr[i]
for i in range(m):
	print(sum - arr[n - var[i]])


n = int(input())
s = []
k = []
d = 0
for i in input().split(' '):
	s.append(int(i))
	d = d + int(i)
s.sort(reverse=True)
m = int(input())
for i in input().split(' '):
	k.append(int(i))
for i in range(0, m):
	print(d - s[k[i] - 1])


chocolates = int(input())
costs = list(map(int, input().split()))
coupon = int(input())
coupons = list(map(int, input().split()))
costs.sort(reverse=True)
total_cost = sum(costs)
for each_coupon in coupons:
	result = total_cost - costs[each_coupon - 1]
	print(result)


n = int(input().strip())
numbers = list(map(int, input().strip().split(' ')))
m = int(input().strip())
qs = tuple(map(int, input().strip().split(' ')))
numbers.sort()
s = 0
for k in range(n):
	s = s + numbers[k]
for k in range(m):
	print(s - numbers[n - qs[k]])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
M = list(map(int, input().split()))
A = sorted(A)
A = A[::-1]
Otv = []
otv = 0
B = [A[0]]
for i in range(1, n):
	B.append(B[-1] + A[i])
for i in range(m):
	otv += B[M[i] - 1]
	otv += B[-1] - B[M[i] - 1]
	otv -= A[M[i] - 1]
	print(otv)
	otv = 0


n = int(input())
a = [int(s) for s in input().split(' ')]
a.sort(reverse=True)
sum_a = sum(a)
m = int(input())
q = [int(s) for s in input().split(' ')]
for i in range(m):
	print(sum_a - a[q[i] - 1])


n = int(input())
cost_bars = list(map(int, input().split()))
num_of_coupons = int(input())
cost_coupouns = list(map(int, input().split()))
cost_bars.sort()
a = sum(cost_bars)
for i in cost_coupouns:
	print(a - cost_bars[-i])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
sum = 0
for cost in a:
	sum += cost
a.sort(reverse=True)
for coupon in q:
	print(sum - a[coupon - 1])


n = int(input())
l = sorted([int(i) for i in input().split()], reverse=True)
m = int(input())
l1 = [int(i) for i in input().split()]
s = sum(l)
for i in range(m):
	print(s - l[l1[i] - 1])


n = int(input())
if n >= 2:
	a = sorted([int(c) for c in input().split(' ')])
	sum = sum(a)
	m = int(input())
	q = [int(ith_coupon) for ith_coupon in input().split(' ')]
	for coupon in q:
		result = sum - a[n - coupon]
		print(result)


def input_as_list():
	return list(map(int, input().split()))
n = int(input())
a = input_as_list()
m = int(input())
q = input_as_list()
a.sort(reverse=True)
s = sum(a)
out = [str(s - a[x - 1]) for x in q]
print('\n'.join(out))


num_chocolates = int(input())
chocolate_list = input().split(' ')
num_coupons = int(input())
coupons_list = input().split(' ')

def to_integer(c_list):
	for i in range(num_chocolates):
		c_list[i] = int(c_list[i])

def calculate_payment(choc_list, coupon_list):
	payment = 0
	current_coupon = 0
	for i in range(num_chocolates - 1, -1, -1):
		payment += choc_list[i]
	while current_coupon < num_coupons:
		print(payment - choc_list[num_chocolates - int(coupon_list[current_coupon])])
		current_coupon += 1
to_integer(chocolate_list)
chocolate_list.sort()
calculate_payment(chocolate_list, coupons_list)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a = sorted(a, reverse=True)
x = sum(a)
for i in b:
	print(x - a[i - 1])


n = int(input())
a = sorted(map(int, input().split()), reverse=True)
m = int(input())
q = [*map(int, input().split())]
t = sum(a)
for i in q:
	print(t - a[i - 1])


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = sum(l)
m = input()
for x in map(int, input().split()):
	print(s - l[-x])


def solve(a, q):
	a.sort()
	sum_a = [0]
	for ai in a:
		sum_a.append(sum_a[-1] + ai)
	back_sum_a = [0]
	for i in reversed(range(len(a))):
		back_sum_a.append(back_sum_a[-1] + a[i])
	back_sum_a.reverse()
	for qi in q:
		yield (back_sum_a[len(a) - qi + 1] + sum_a[len(a) - qi])

def main() -> None:
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	q = list(map(int, input().split()))
	print(*solve(a, q), sep='\n')
main()


n = int(input())
l = list(map(int, input().split()))
sum1 = sum(l)
l.sort(reverse=True)
q = int(input())
q1 = list(map(int, input().split()))
for i in q1:
	print(sum1 - l[i - 1])


n = int(input())
a = sorted([int(x) for x in input().split()], reverse=True)
s = sum(a)
m = int(input())
qs = [int(x) for x in input().split()]
for q in qs:
	print(s - a[q - 1])


from sys import stdin
from collections import Counter, defaultdict, deque
from math import sqrt, factorial, log10, log, floor, ceil
from itertools import permutations, combinations, combinations_with_replacement, product
input = stdin.readline

def li():
	return list(map(int, input().split()))

def lis():
	return list(map(str, input().split()))

def mp():
	return map(int, input().split())

def inp():
	return int(input())

def inps():
	return str(input().strip())

def pr(n):
	return stdout.write(str(n) + '\n')

def primes(pmax):
	D = {}
	q = 2
	while q <= pmax:
		if q not in D:
			yield q
			D[q * q] = [q]
		else:
			for p in D[q]:
				D.setdefault(p + q, []).append(p)
			del D[q]
		q += 1

def gcd(i, j):
	while j > 0:
		(i, j) = (j, i % j)
	return i
INF = float('inf')

def solve():
	n = inp()
	a = li()
	a.sort()
	q = inp()
	b = li()
	sm = sum(a)
	for i in b:
		print(sm - a[n - i])
t = 1
for i in range(t):
	solve()


input()
a = list(map(int, input().split()))
s = sum(a)
a.sort(reverse=True)
input()
q = list(map(int, input().split()))
for i in range(len(q)):
	print(s - a[q[i] - 1])


from math import *
from collections import deque
from copy import deepcopy
import sys

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def multi():
	return map(int, input().split())

def strmulti():
	return map(str, inp().split())

def lis():
	return list(map(int, inp().split()))

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def stringlis():
	return list(map(str, inp().split()))

def out(var):
	sys.stdout.write(str(var))

def printlist(a):
	print(' '.join((str(a[i]) for i in range(len(a)))))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
n = int(input())
a = lis()
m = int(input())
b = lis()
a.sort()
sum = 0
for i in a:
	sum += i
for i in b:
	print(sum - a[-i])


amount = int(input())
array = [int(s) for s in input().split()]
m = int(input())
cups = [int(s) for s in input().split()]
array = sorted(array)
sum_ = sum(array)
for i in range(m):
	print(sum_ - array[-cups[i]])


n = int(input())
price = [int(x) for x in input().split()]
total_price = sum(price)
no_of_coupons = int(input())
coupons = [int(x) for x in input().split()]
price.sort()
for i in range(no_of_coupons):
	print(total_price - price[0 - coupons[i]])


n_chocolate = int(input())
c_chocolate = list(map(int, input().split(' ')))
n_coupons = int(input())
v_coupons = list(map(int, input().split(' ')))
c_chocolate.sort(reverse=True)
total_chocolate = sum(c_chocolate)
for i in range(n_coupons):
	print(total_chocolate - c_chocolate[v_coupons[i] - 1])


n = int(input())
chocolates = list(map(int, input().split(' ')))
k = int(input())
cupons = list(map(int, input().split(' ')))
sorted_list = sorted(chocolates)
soma = sum(sorted_list)
for cupom in cupons:
	discount = sorted_list[n - cupom]
	b = soma - discount
	print(soma - discount)


n = int(input().strip())
a1 = list(map(int, input().split()))
m = int(input().strip())
a2 = list(map(int, input().split()))
empty = []
a1.sort()
total = sum(a1)
for i in a2:
	print(total - a1[n - i])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort()
b = sum(a)
for i in range(m):
	print(b - a[n - q[i]])


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return list(map(int, input().split()))

def lm():
	return list(map(int, input().split()))
n = nn()
l = lm()
q = nn()
qs = lm()
l.sort()
s = sum(l)
for c in qs:
	print(s - l[-c])


def sol(S, k):
	return S - c[len(c) - k]
from functools import reduce
n = int(input())
c = sorted(list(map(lambda x: int(x), input().split(' '))))
m = input()
q = list(map(lambda x: int(x), input().split(' ')))
S = reduce(lambda x, y: x + y, c)
for k in q:
	print(sol(S, k))


numChoc = int(input())
chocsVal = list()
chocsVal = input().split(' ')
for i in range(len(chocsVal)):
	chocsVal[i] = int(chocsVal[i])
chocsVal.sort()
numCoupons = int(input())
qtdToBuy = list()
qtdToBuy = input().split(' ')
total = sum(chocsVal, 0)
for k in range(numCoupons):
	print(total - chocsVal[numChoc - int(qtdToBuy[k])])


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mm = 1000000007

def solve():
	t = 1
	for it in range(t):
		n = nu()
		a = li()
		a.sort()
		q = nu()
		b = li()
		pre = []
		pre.append(a[0])
		for i in range(1, n):
			pre.append(pre[i - 1] + a[i])
		for i in range(q):
			pp = b[i]
			kp = n - pp
			ss = 0
			if kp == 0:
				ss = pre[n - 1] - pre[kp]
			else:
				ss = pre[n - 1] - pre[kp] + pre[kp - 1]
			print(ss)
solve()


n = int(input())
choco = input().split()
m = int(input())
kupon = input().split()
intts = []
for i in range(n):
	intts.append(int(choco[i]))
intts.sort(reverse=True)
total = 0
for i in range(n):
	total += intts[i]
for i in range(m):
	answer = total - intts[int(kupon[i]) - 1]
	print(answer)


n = int(input())
bars = list(map(int, input().strip().split()))
bars.sort()
m = int(input())
coupons = list(map(int, input().strip().split()))
s = sum(bars)
for i in coupons:
	print(s - bars[-i])


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
a = sorted(a, reverse=True)
sa = sum(a)
m = int(input())
ql = input().split()
for i in range(m):
	q = int(ql[i]) - 1
	tot = sa - a[q]
	print(tot)


n = int(input())
bars = list(map(int, input().split()))
bars.sort(reverse=True)
s = sum(bars)
t = int(input())
coupons = list(map(int, input().split()))
for i in coupons:
	print(s - bars[i - 1])


nbar = int(input())
precos = input().split()
ncups = int(input())
cupons = input().split()
for x in range(nbar):
	precos[x] = int(precos[x])
precos.sort()
soma = sum(precos)
for x in range(ncups):
	cupons[x] = int(cupons[x])
for i in range(ncups):
	print(soma - precos[-cupons[i]])


n = int(input())
p = list(map(int, input().split()))
tsum = sum(p)
p.sort(reverse=1)
d = int(input())
sr = [-1] * d
di = list(map(int, input().split()))
for i in range(d):
	if sr[i] == -1:
		sr[i] = tsum - p[di[i] - 1]
	print(sr[i])


n = int(input())
a = sorted(list(map(int, input().split())))
k = sum(a)
q = int(input())
b = list(map(int, input().split()))
for i in b:
	print(k - a[n - i])


n = input()
bars_prices = list(map(int, input().split()))
n_cupons = input()
cupons = list(map(int, input().split()))
bars_prices.sort()
bars_prices.reverse()
total_price = sum(bars_prices)
for i in cupons:
	print(total_price - bars_prices[i - 1])


n = int(input())
ar = list(map(int, input().split()))
ar = sorted(ar, reverse=True)
m = int(input())
arcoup = list(map(int, input().split()))
n = sum(ar)
for q in arcoup:
	print(n - ar[q - 1])


n = int(input())
lis = list(map(int, input().split(' ')))
m = int(input())
cpn = list(map(int, input().split(' ')))
sm = sum(lis)
lis = sorted(lis, reverse=True)
for c in cpn:
	print(sm - lis[c - 1])


(n, a) = (input(), map(int, input().split()))
(m, q) = (input(), map(int, input().split()))
a = sorted(a)
total = sum(a)
for i in q:
	print(total - a[-i])


n = int(input())
cost = list(map(int, input().split()))
m = int(input())
dc = list(map(int, input().split()))
cost.sort(reverse=True)
tsum = sum(cost)
for i in range(m):
	ans = tsum - cost[dc[i] - 1]
	print(ans)


n = int(input())
cho = list(map(int, input().split()))
m = int(input())
cpn = list(map(int, input().split()))
cho.sort()
s = sum(cho)
for i in range(m):
	print(s - cho[-cpn[i]])


n = int(input())
a = list(map(int, input().split()))
a.sort()
m = int(input())
q = list(map(int, input().split()))
s = sum(a)
for i in q:
	print(s - a[n - i])


n = int(input())
t = list(map(int, input().split()))
y = int(input())
s = list(map(int, input().split()))
t.sort()
p = sum(t)
for k in range(y):
	print(p - t[n - s[k]])


def sorted(a):
	result = a.copy()
	result.sort()
	return result
n = int(input())
a = [int(x) for x in input().split()]
input()
q = [int(x) for x in input().split()]
sorted_costs = sorted(a)
cost_without_discount = sum(a)
for coupon_chocolates_count in q:
	print(cost_without_discount - sorted_costs[n - coupon_chocolates_count])


n = int(input())
ai = list(map(int, input().split()))
m = int(input())
qi = list(map(int, input().split()))
ai.sort()
summ = sum(ai)
for i in range(m):
	print(summ - ai[n - qi[i]])


n = int(input())
l = list(map(int, input().split()))
m = int(input())
li = list(map(int, input().split()))
l.sort()
su = sum(l)
for i in range(m):
	print(su - l[-li[i]])


n = int(input())
prices = list(map(int, input().split()))
m = int(input())
coupons = list(map(int, input().split()))
prices.sort(reverse=True)
s = sum(prices)
res = []
for c in coupons:
	res.append(s - prices[c - 1])
for r in res:
	print(r)


n = int(input())
a1 = list(map(int, input().split()))
a1.sort(reverse=True)
s1 = sum(a1)
m = int(input())
a2 = list(map(int, input().split()))
for i in a2:
	s = 0
	i -= 1
	s = s1 - a1[i]
	print(s)


n = int(input())
arr_str = input().split()
arr = [int(x) for x in arr_str]
n_coup = int(input())
coup_str = input().split()
coup_arr = [int(x) for x in coup_str]
arr.sort(reverse=True)
cum_sum = 0
for i in range(len(arr)):
	cum_sum += arr[i]
for coupon in coup_arr:
	ans = cum_sum - arr[coupon - 1]
	print(ans)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
x = int(input())
m = list(map(int, input().split()))
final = 0
for i in l:
	final += i
for i in m:
	print(final - l[-1 * i])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort()
a.reverse()
s = sum(a)
for item in q:
	print(s - a[item - 1])


n = int(input())
x = str(input())
x = x.split(' ')
x = [int(b) for b in x if b != '']
n2 = int(input())
y = str(input())
y = y.split(' ')
y = [int(b) for b in y if b != '']
x = sorted(x, reverse=True)
s = 0
for j in range(n):
	s = s + x[j]
for i in range(n2):
	print(s - x[y[i] - 1])


n = int(input())
prices = [int(x) for x in input().split()]
m = int(input())
cupons = [int(x) for x in input().split()]
prices.sort(reverse=True)
sum_g = sum(prices)
results = []
for i in cupons:
	sum_c = sum_g - prices[i - 1]
	results.append(str(sum_c))
print('\n'.join(results))


import sys, queue
sys.setrecursionlimit(1000000)
n = int(input())
c = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
c.sort(reverse=True)
s = sum(c)
for mi in q:
	print(s - c[mi - 1])


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
sm = sum(arr)
m = int(input())
arr2 = [int(x) for x in input().split()]
for i in range(m):
	print(sm - arr[-arr2[i]])


n = int(input())
cost = [int(i) for i in input().split()]
m = int(input())
s = sum(cost)
cost.sort(reverse=True)
coup = [int(i) for i in input().split()]
for i in coup:
	print(s - cost[i - 1])


chocolates = int(input())
prices = sorted([int(i) for i in input().split()], reverse=True)
totalSum = sum(prices)
vouchers = int(input())
vouchersLimitations = input().split()
for i in vouchersLimitations:
	print(totalSum - prices[int(i) - 1])


n = int(input())
l = [int(i) for i in input().split()]
l.sort()
m = int(input())
l1 = [int(i) for i in input().split()]
a = sum(l)
for i in l1:
	print(a - l[-i])


nbars = int(input())
precos = str(input())
ncupons = int(input())
cupons = str(input())
soma = 0
minimo = 0
listap = list(map(int, precos.split()))
listap.sort()
tamanho = len(listap)
listacup = cupons.split()
for b in listap:
	soma = soma + b
for a in listacup:
	local = 0
	local = tamanho - int(a)
	minimo = listap[local]
	soma = soma - minimo
	print(soma)
	soma = soma + minimo


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
m = int(input())
q = list(map(int, input().split()))
pref = [0]
for i in a:
	pref.append(pref[-1] + i)
for i in q:
	dis = n - i
	print(pref[i - 1] + pref[-1] - pref[i])


n = int(input())
read = input().split()
a = sorted([int(x) for x in read])
sum_a = sum(a)
m = int(input())
q = input().split()
for i in range(m):
	print(sum_a - a[n - int(q[i])])


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
brr = list(map(int, input().split()))
arr = sorted(arr)
tot = sum(arr)
for i in brr:
	print(tot - arr[-i])


a = int(input())
b = list(map(int, input().split()))
j = sum(b)
c = int(input())
k = list(map(int, input().split()))
b = sorted(b)
for i in range(c):
	print(j - b[-k[i]])


import sys
n = int(sys.stdin.readline())
ch = str(sys.stdin.readline()[:-1]).split(' ')
m = int(sys.stdin.readline())
cup = str(sys.stdin.readline()[:-1]).split(' ')
ch = [int(x) for x in ch]
ch.sort()
s = sum(ch)
for c in cup:
	print(s - ch[n - int(c)])


quantidade_barras = int(input())
preco_barras = list(map(int, input().split()))
quantidade_cupons = int(input())
descontos_possiveis = list(map(int, input().split()))
preco = sum(preco_barras)
preco_barras.sort(reverse=True)
for i in range(quantidade_cupons):
	print(preco - preco_barras[descontos_possiveis[i] - 1])


n = int(input())
a = sorted(list(map(int, input().split())))
a.reverse()
m = int(input())
q = list(map(int, input().split()))
z = sum(a)
for i in q:
	print(z - a[i - 1])


def main():
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	q = list(map(int, input().split()))
	a.sort(reverse=True)
	total_cost = sum(a)
	for coupon in q:
		print(total_cost - a[coupon - 1])
main()


def rli():
	return list(map(int, input().split()))

def main():
	int(input())
	nums = rli()
	int(input())
	qs = rli()
	ans = sum(nums)
	nums.sort()
	for q in qs:
		print(ans - nums[-q])
main()


a = int(input())
b = list(map(int, input().split()))
c = int(input())
d = list(map(int, input().split()))
b.sort()
g = sum(b)
for i in range(c):
	print(g - b[-d[i]])


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	a = LI()
	m = I()
	q = LI()
	r = []
	b = sorted(a, reverse=True)
	s = sum(b)
	for c in q:
		r.append(s - b[c - 1])
	return '\n'.join(map(str, r))
print(main())


n = int(input())
l1 = list(map(int, input().split()))
k = int(input())
l2 = list(map(int, input().split()))
l1.sort()
l1.reverse()
x = sum(l1)
for i in l2:
	print(x - l1[i - 1])


sizee = int(input())
choco_list = [*map(int, input().split())]
choco_list.sort()
choco_list.reverse()
input()
b = [*map(int, input().split())]
total = 0
for i in range(sizee):
	total += choco_list[i]
for a in b:
	print(total - choco_list[a - 1])


n = int(input())
price = list(map(int, input().split()))
m = int(input())
coupon = list(map(int, input().split()))
price.sort()
price.reverse()
sum = 0
for i in price:
	sum += i
for i in range(m):
	print(sum - price[coupon[i] - 1])


n = int(input())
A = [*map(int, input().split())]
m = int(input())
Q = [*map(int, input().split())]
A.sort(reverse=True)
sum_ = sum(A)
for i in range(m):
	j = Q[i]
	print(sum_ - A[j - 1])


n = int(input())
prices = input()
prices = prices.split()
m = int(input())
coupons = input()
coupons = coupons.split()
for i in range(len(prices)):
	prices[i] = int(prices[i])
prices.sort()
total = sum(prices)
for coupon in coupons:
	start = len(prices) - 1 - (int(coupon) - 1)
	print(total - prices[start])


size = int(input())
arr = input().split(' ')
m = int(input())
coupons = input().split(' ')
arr = list(map(int, arr))
arr = sorted(arr)
cost = sum(arr)
for i in coupons:
	i = int(i)
	loc_cost = cost - arr[-i]
	print(loc_cost)


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a)
q = int(input())
c = list(map(int, input().split()))
for i in c:
	print(s - a[i - 1])


n = int(input())
s = sorted(map(int, input().split()))
m = int(input())
ans = sum(s)
for i in map(int, input().split()):
	print(ans - s[-i])


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
m = int(input())
discount = list(map(int, input().split()))
sum_ = sum(arr)
for i in range(m):
	print(sum_ - arr[n - discount[i]])


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
x = sum(a)
m = int(input())
q = [int(i) for i in input().split()]
for i in q:
	t = a[n - i]
	ans = x - t
	print(ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
res = sum(a)
m = int(input())
q = list(map(int, input().split()))
for x in q:
	print(res - a[-x])


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
a = I()
a.sort(reverse=True)
s = sum(a)
(m,) = I()
for i in I():
	print(s - a[i - 1])


def task2():
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	m = int(input())
	q = [int(x) for x in input().split()]
	summ = sum(a)
	for i in range(m):
		print(summ - a[q[i] - 1])
task2()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort()
sm = sum((i for i in a))
for _ in q:
	print(sm - a[n - _], end=' ')


n = int(input())
a = [int(x) for x in input().split(' ')]
m = int(input())
q = [int(x) for x in input().split(' ')]
a.sort()
s = sum(a)
for c in q:
	ans = s - a[-c]
	print(ans)


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
res = 0
for i in A:
	res = res + i
list.sort(A)
for i in B:
	print(res - A[n - i])


n = int(input(''))
cost = list(map(int, input('').split()))
m = int(input(''))
tick = list(map(int, input('').split()))
cost.sort()
cost = cost[::-1]
s = sum(cost)
for i in range(m):
	print(s - cost[tick[i] - 1])


n = int(input())
bars = sorted(list(map(int, input().split())), reverse=True)
m = int(input())
q = list(map(int, input().split()))
total = sum(bars)
for i in range(m):
	print(total - bars[q[i] - 1])


n = int(input())
costs = [int(i) for i in input().split(' ')]
m = int(input())
coupons = [int(i) for i in input().split(' ')]
chocs = costs[:]
chocs.sort()
chocs = chocs[::-1]
total_sum = sum(chocs)
for coupon in coupons:
	tmp = total_sum - chocs[coupon - 1]
	print(tmp)


(n,) = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
(m,) = map(int, input().split())
C = list(map(int, input().split()))
ans = 0
for i in P:
	ans += i
for i in C:
	temp = ans - P[i - 1]
	print(temp)


n = int(input())
s = input().split()
s1 = [int(k) for k in s]
s2 = sorted(s1)
sum_s = sum(s2)
m = int(input())
q = [int(l) for l in input().split()]
for j in q:
	print(sum_s - s2[-j])


n = int(input())
A = sorted([int(a) for a in input().split()])[::-1]
m = int(input())
Q = [int(a) for a in input().split()]
s = sum(A)
for q in Q:
	print(s - A[q - 1])


num = int(input())
c = list(map(int, input().split()))
ss = sum(c)
c.sort()
miphone = int(input())
ccL = list(map(int, input().split()))
c.sort()
for i in ccL:
	print(ss - c[num - i])


n = int(input())
bars = list(map(int, input().split()))
bars.sort()
m = int(input())
cupons = list(map(int, input().split()))
total = sum(bars)

def solve(n):
	return total - bars[-cupon]
for cupon in cupons:
	print(solve(cupon))


n = int(input())
A = list(map(int, input().split()))
m = int(input())
Q = list(map(int, input().split()))
A.sort(reverse=True)
sum = 0
for i in range(n):
	sum += A[i]
for i in range(m):
	print(sum - A[Q[i] - 1])


n = int(input())
sweets = [int(x) for x in input().split(' ')]
m = int(input())
sale = [int(x) for x in input().split(' ')]
d = sum(sweets)
sweets.sort()
for i in range(m):
	q = sale[i]
	print(d - sweets[n - q])


n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l1.sort()
x = sum(l1)
l2 = list(map(int, input().split()))
for item in l2:
	print(x - l1[n - item])


nbars = int(input())
bars = list(map(int, input().split(' ')))
ncoup = int(input())
coups = list(map(int, input().split(' ')))
bars.sort(reverse=True)
sumbars = sum(bars)
for k in coups:
	if k > 0:
		soma = sumbars - bars[k - 1]
		print(soma)


n = int(input())
chc = list(map(int, input().split()))
m = int(input())
val = list(map(int, input().split()))
t = sum(chc)
chc.sort()
for elem in val:
	print(t - chc[n - elem])


input()
a = sorted(map(int, input().split()), reverse=True)
x = sum(a)
input()
for i in map(int, input().split()):
	print(x - a[i - 1])


n = int(input())
p = input().split()
for i in range(n):
	p[i] = int(p[i])
p.sort()
soma = sum(p)
c = int(input())
d = input().split()
for i in range(c):
	print(soma - p[n - int(d[i])])


n = int(input())
chocoloat = input().split(' ')
m = int(input())
kup = input().split(' ')
for i in range(n):
	chocoloat[i] = int(chocoloat[i])
chocoloat.sort(reverse=True)
summa = sum(chocoloat)
rez = []
for i in range(m):
	rez.append(summa - chocoloat[int(kup[i]) - 1])
for i in range(len(rez)):
	print(rez[i])


n = int(input())
tot = int(0)
ar = input().split()
q = int(input())
qList = input().split()
ar = list(map(int, ar))
qList = list(map(int, qList))
for i in ar:
	tot += i
ar.sort(reverse=True)
for x in qList:
	print(tot - ar[x - 1])


n = (int(i) for i in input().strip().split())
a = [int(i) for i in input().strip().split()]
m = (int(i) for i in input().strip().split())
q = [int(i) for i in input().strip().split()]
a = sorted(a, reverse=True)
arr = [a[0]]
for i in range(1, len(a)):
	arr.append(arr[i - 1] + a[i])
sum = arr[len(arr) - 1]
for i in range(0, len(q)):
	print(sum + arr[q[i] - 2] - arr[q[i] - 1])


_ = input()
prices = list(map(int, input().split()))
prices.sort(reverse=True)
s = sum(prices)
m = int(input())
qs = list(map(int, input().split()))
for q in qs:
	print(s - prices[q - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a = sorted(a, reverse=True)
rec = []
for i in range(m):
	rec.append((q[i], i))
rec = sorted(rec)
ans = [0] * m
s = sum(a)
for i in range(m):
	ans[rec[i][1]] = s - a[rec[i][0] - 1]
for i in range(m):
	print(ans[i])


n = int(input())
ls = list(map(int, input().split()))
m = int(input())
ls1 = list(map(int, input().split()))
ls.sort(reverse=True)
sum = 0
for i in range(0, n):
	sum += ls[i]
for i in range(0, m):
	print(sum - ls[ls1[i] - 1])


input()
a = list(map(int, input().split()))
input()
q = list(map(int, input().split()))
a.sort()
sa = sum(a)
for qq in q:
	print(sa - a[-qq])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
Q = list(map(int, input().split()))
sum = 0
A.sort()
for i in A:
	sum += i
for i in Q:
	print(sum - A[-i])


n = int(input())
l = sorted(list(map(int, input().split())))
s = sum(l)
m = int(input())
q = list(map(int, input().split()))
for i in range(m):
	print(s - l[n - q[i]])


n = int(input())
a = list(map(int, input().strip().split(' ')))
a.sort(reverse=True)
p = int(input())
b = list(map(int, input().strip().split(' ')))
r = sum(a)
for j in b:
	print(r - a[j - 1])


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
(n, cost, m, coupon) = (int(input()), ll(), int(input()), ll())
cost.sort()
s = sum(cost)
ans = [0] * m
for (i, v) in enumerate(coupon):
	ans[i] = s - cost[-v]
print('\n'.join(map(str, ans)))


n = int(input())
a = [int(i) for i in input().split(' ')]
q = int(input())
Q = [int(i) for i in input().split(' ')]
s = sum(a)
a.sort()
for i in Q:
	print(s - a[-i])


n = int(input())
l = list(map(int, input().split()))
add = sum(l)
l.sort(reverse=True)
m = int(input())
q = list(map(int, input().split()))
for i in range(m):
	sum1 = add
	sum1 = sum1 - l[q[i] - 1]
	print(sum1)


n = int(input())
l = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
ans = []
l.sort()
suml = sum(l)
for i in range(len(q)):
	print(suml - l[len(l) - q[i]])


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict
import math
import heapq

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
n = intIn()
a = listIn()
m = intIn()
q = listIn()
a.sort()
S = sum(a)
for i in range(m):
	print(S - a[-q[i]])


N = int(input())
costs = sorted([int(i) for i in input().split()], reverse=True)
total = sum(costs)
C = int(input())
coupons = [int(i) for i in input().split()]
for coup in coupons:
	print(total - costs[coup - 1])


n_cho = int(input())
chos = list(map(int, list(input().split())))
n_cpn = int(input())
cpns = list(map(int, list(input().split())))
chos.sort()
soma_total = sum(chos)
for c in cpns:
	soma = soma_total - chos[-1 * c]
	print(soma)


fuck = input()
candy = [int(x) for x in input().split()]
fuck2 = input()
cupon = [int(y) for y in input().split()]
candy.sort(reverse=True)
all = int(sum(candy))
for i in cupon:
	tmp = []
	tmp = candy
	use_num = int(i)
	print(all - tmp[use_num - 1])


class Chocolate:

	def __init__(self, index, price):
		self.index = index
		self.price = price

def cv(c):
	return c.price

def main():
	n = int(input())
	a = [int(e) for e in input().split()]
	m = int(input())
	q = [int(e) for e in input().split()]
	s = sum(a)
	c = [None] * n
	for i in range(n):
		c[i] = Chocolate(i, a[i])
	c.sort(key=cv)
	for coupon in q:
		print(s - c[-coupon].price)
	return 0
main()


n = int(input())
l1 = list(map(int, input().split()))
q = int(input())
l2 = list(map(int, input().split()))
l1.sort()
s = sum(l1)
for i in l2:
	print(s - l1[n - i])


choco = int(input())
preco = input().split()
for x in range(choco):
	preco[x] = int(preco[x])
cupom = int(input())
cup = input().split()
soma = 0
preco = sorted(preco, reverse=True)
for x in range(cupom):
	cup[x] = int(cup[x])
for x in range(choco):
	soma = soma + preco[x]
valor = 0
for i in range(cupom):
	valor = cup[i]
	print(soma - preco[valor - 1])


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
pre = [0] * (n + 1)
q = int(input())
brr = list(map(int, input().split()))
for i in range(n):
	pre[i + 1] = pre[i] + arr[i]
for i in range(q):
	print(pre[n - brr[i]] + pre[n] - pre[n - brr[i] + 1])


n = int(input())
costs = sorted([int(a) for a in input().split(' ')])
m = int(input())
qs = input().split(' ')
sm = sum(costs)
for el in qs:
	print(sm - costs[n - int(el)])


import collections
n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort()
total = sum(a)
for i in q:
	print(total - a[-i])


I = lambda : map(int, input().split())
I()
l = sorted(I())
s = sum(l)
I()
for q in I():
	print(s - l[-q])


n = input()
costs = list(map(int, input().strip().split()))
m = input()
coupon = list(map(int, input().strip().split()))

def mergelists(l, r):
	if isinstance(l, int):
		mx = max(l, r)
		mn = min(l, r)
		return [mn, mx]
	li = 0
	ri = 0
	ans = []
	while li < len(l) and ri < len(r):
		if l[li] < r[ri]:
			ans.append(l[li])
			li += 1
		else:
			ans.append(r[ri])
			ri += 1
	if li == len(l):
		ans.extend(r[ri:])
	else:
		ans.extend(l[li:])
	return ans

def mergesort(l):
	length = len(l)
	if length == 0:
		return []
	i = 0
	ans = []
	while i < length - 1:
		ans.append(mergelists(l[i], l[i + 1]))
		i += 2
	if length % 2 and isinstance(l[length - 1], int):
		ans.append([l[length - 1]])
	elif length % 2:
		ans.append(l[length - 1])
	if len(ans) == 1:
		return ans[0]
	else:
		return mergesort(ans)
costs = mergesort(costs)
ans = 0
for i in costs:
	ans += i
for i in coupon:
	print(ans - costs[-i])


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
q = int(input())
d = list(map(int, input().split()))
x = [l[0]]
s = l[0]
for i in range(1, n):
	s = s + l[i]
	x.append(s)
for i in range(q):
	z = x[d[i] - 2] + x[n - 1] - x[d[i] - 1]
	print(z)


n = int(input())
list = [int(i) for i in input().split()]
list.sort()
sum = 0
for i in list:
	sum += i
m = int(input())
lis = [int(i) for i in input().split()]
for i in range(m):
	print(sum - list[n - lis[i]])


n1 = int(input())
l1 = [int(x) for x in input().split()]
l1.sort(reverse=True)
n2 = int(input())
l2 = [l1[int(x) - 1] for x in input().split()]
k = sum(l1)
for x in l2:
	print(k - x)


def main():
	n = int(input())
	cost = list(map(int, input().split()))
	total = sum(cost)
	m = int(input())
	cost.sort(reverse=True)
	discount = list(map(int, input().split()))
	for i in range(m):
		q = discount[i]
		curr = total - cost[q - 1]
		print(curr)
main()


n = int(input())
l = list(map(int, input().split()))
k = int(input())
m = list(map(int, input().split()))
l.sort(reverse=1)
sm = sum(l)
for i in m:
	print(sm - l[i - 1])


n = int(input())
l = list(map(int, input().split()))
m = int(input())
k = list(map(int, input().split()))
l.sort()
tot = sum(l)
for i in k:
	print(tot - l[-i])


n = int(input())
a = input().split()
m = int(input())
q = input().split()
a = [int(item) for item in a]
q = [int(item) for item in q]
a.sort()
a.reverse()
d = sum(a)
for i in range(m):
	f = a[q[i] - 1]
	print(d - f)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
dp = [0] * n
a.sort(reverse=True)
dp[0] = sum(a[1:])
for i in range(1, n):
	dp[i] = dp[i - 1] + a[i - 1] - a[i]
for x in q:
	print(dp[x - 1])


n = int(input())
candy = [int(i) for i in input().strip().split()]
m = input()
coupon = [int(i) for i in input().strip().split()]
s = sum(candy)
candy.sort(reverse=True)
optimal_cost = [0] * n
for (i, num) in enumerate(candy):
	optimal_cost[i] = s - candy[i]
for (i, num) in enumerate(coupon):
	print(optimal_cost[num - 1])


n = int(input())
price = list(map(int, input().split()))
m = int(input())
coupons = list(map(int, input().split()))
d = sorted(price)
summ = sum(d)
for i in coupons:
	k = d[n - i]
	print(summ - k)


try:
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	q = list(map(int, input().split()))
	a.sort()
	sum1 = sum(a)
	for i in q:
		ans = sum1 - a[n - i]
		print(ans)
except:
	print(a)
	print(q)


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
q = [int(i) for i in input().split()]
x = sorted(a)
x.reverse()
summ = sum(x)
for i in q:
	sumx = summ - x[i - 1]
	print(sumx)


def main():
	n = int(input())
	prices = [int(_) for _ in input().split()]
	prices.sort(reverse=True)
	s = sum(prices)
	input()
	coupons = [int(_) for _ in input().split()]
	for i in coupons:
		print(s - prices[i - 1])
main()


n = int(input())
lst = list(map(int, input().split()))
tot = sum(lst)
lst.sort()
m = int(input())
q = list(map(int, input().split()))
for i in q:
	print(tot - lst[n - i])


input()
X = sorted(list(map(int, input().split())), reverse=True)
SUM = sum(X)
input()
C = list(map(int, input().split()))
for i in C:
	print(SUM - X[i - 1])


n = int(input())
mat = list(map(int, input().split()))
input()
sat = list(map(int, input().split()))
mat = sorted(mat)
tot_sum = sum(mat)
for i in sat:
	sp = n - i
	print(tot_sum - mat[sp])


n = int(input())
chocolates = list(map(int, input().split()))
m = int(input())
cupons = list(map(int, input().split()))
barchocolates = 0
chocolates.sort()
barchocolates = sum(chocolates)
for e in cupons:
	resposta = barchocolates - chocolates[n - e]
	print(resposta)


(n, a, m, p) = (input() for i in range(4))
a = [int(x) for x in a.split(' ')]
p = [int(x) for x in p.split(' ')]
a.sort()
summ = sum(a)
for i in p:
	print(summ - a[-i])


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
m = int(input())
b = list(map(int, input().split()))
sm = sum(a)
for i in range(m):
	print(sm - a[b[i] - 1])


n = int(input())
bars = list(map(int, input().split()))
m = int(input())
coupons = list(map(int, input().split()))
bars = sorted(bars, reverse=True)
total = sum(bars)
for i in range(m):
	index = coupons[i] - 1
	answer = total - bars[index]
	print(answer)


n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a:
	s += i
a.sort()
m = int(input())
b = list(map(int, input().split()))
for i in b:
	print(s - a[len(a) - i])


def main():
	n = int(input())
	aa = [int(i) for i in input().split()]
	m = int(input())
	qq = [int(i) for i in input().split()]
	aa = sorted(aa)
	ss = sum(aa)
	for i in range(m):
		k = qq[i]
		if n - k >= 0:
			x = aa[-k]
		else:
			x = aa[qq[0]]
		ans = ss - x
		print(ans)
main()


n = int(input())
l = [int(x) for x in input().split()]
g = sum(l)
l.sort(reverse=True)
m = int(input())
lm = [int(y) for y in input().split()]
for i in lm:
	print(g - l[i - 1])


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
_ = int(input())
Choco = list(map(int, input().split()))
S = sum(Choco)
M = int(input())
Coup = list(map(int, input().split()))
Choco = sorted(Choco, reverse=True)
ans = []
for c in Coup:
	ans.append(S - Choco[c - 1])
print('\n'.join(map(str, ans)))


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	ans = sum(a)
	a.sort(reverse=True)
	q = int(input())
	qq = list(map(int, input().split(' ')))
	for x in qq:
		print(ans - a[x - 1])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = 1
for test in range(t):
	n = int(input())
	c = list(map(int, input().split()))
	m = int(input())
	q = list(map(int, input().split()))
	c.sort()
	ans = sum(c)
	for i in q:
		print(ans - c[n - i])


n = int(input())
a = list(map(int, input().split()))
lul = sum(a)
a.sort(reverse=True)
lul_nenuznaya = int(input())
v = list(map(int, input().split()))
for i in v:
	print(lul - a[i - 1])


n = int(input())
s = 0
prc = list(map(int, input().split()))
for x in range(n):
	s = s + prc[x]
prc.sort(reverse=True)
q = int(input())
c = list(map(int, input().split()))
for x in c:
	print(s - prc[x - 1])


N = int(input())
ls = list(map(int, input().split()))
ls.sort()
m = int(input())
m = list(map(int, input().split()))
S = sum(ls)
for j in m:
	print(S - ls[-1 * j])


n = int(input())
l = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
su = sum(l)
l.sort(reverse=True)
for i in q:
	print(su - l[i - 1])


a = int(input())
A = list(map(int, input().split()))
b = int(input())
B = list(map(int, input().split()))
A.sort(reverse=True)
suma = sum(A)
for i in range(b):
	print(suma - A[B[i] - 1])


mi = lambda : [int(i) for i in input().split()]
n = int(input())
a = sorted(mi())
m = int(input())
q = mi()
s = sum(a)
for i in q:
	print(s - a[-i])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
ans = 0
ans1 = 0
for i in range(n):
	ans1 += a[i]
ans = ans1
b = list(map(int, input().split()))
a.sort(reverse=True)
for i in range(m):
	ans -= a[b[i] - 1]
	print(ans)
	ans += a[b[i] - 1]


n = int(input())
l = list(map(int, input().split()))
l.sort()
m = int(input())
p = list(map(int, input().split()))
r = sum(l)
for i in range(m):
	print(r - l[n - p[i]])


x = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
y = int(input())
b = list(map(int, input().split()))
c = sum(a)
for i in b:
	print(c - a[i - 1])


n = int(input())
l = [int(i) for i in input().split(' ')]
a = int(input())
p = [int(j) for j in input().split(' ')]
l.sort()
v = sum(l)
s = len(l)
for k in p:
	print(v - l[s - k])


n = int(input())
l = list(map(int, input().split()))
q = int(input())
ql = list(map(int, input().split()))
l.sort()
s = sum(l)
for i in ql:
	print(s - l[-i])


n = int(input())
stoimost_sh = [int(i) for i in input().split()]
m = int(input())
qupon = [int(i) for i in input().split()]
stoimost_sh.sort()
suma_vsego = sum(stoimost_sh)
for i in range(m):
	print(suma_vsego - stoimost_sh[-qupon[i]])


nv = int(input())
v = input().split()
nd = int(input())
d = input().split()
t = 0
for i in range(nv):
	v[i] = int(v[i])
	t += v[i]
v.sort()
for i in range(nd):
	p = int(d[i])
	print(t - int(v[-p]))


n = int(input())
co = 0
a = [int(x) for x in input().split()]
a.sort(reverse=True)
z = sum(a)
m = int(input())
b = [int(x) for x in input().split()]
for i in range(m):
	print(z - a[b[i] - 1])


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))
n = I()
A = sorted(IL())
sA = sum(A)
m = I()
Q = IL()
for q in Q:
	print(sA - A[-q])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
z = sum(a)
for i in b:
	print(z - a[-i])


n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
cop = []
for i in a:
	cop.append(i)
tec = a[0]
q = int(input())
qq = [int(x) for x in input().split()]
d = sum(a)
for i in range(q):
	x = qq[i]
	print(d - cop[-x])


n = input()
prices = sorted([int(i) for i in input().split()])
n = input()
coupons = [int(i) for i in input().split()]
totalPrice = sum(prices)
for coupon in coupons:
	print(totalPrice - prices[len(prices) - coupon])


n = int(input())
a = list(map(int, input().split()))
b = int(input())
c = list(map(int, input().split()))
a.sort()
s = sum(a)
for i in range(b):
	print(s - a[n - c[i]])


n = int(input())
arr = list(map(int, input().split()))
c = int(input())
sum = 0
arr1 = list(map(int, input().split()))
arr.sort(reverse=True)
for i in range(0, n):
	sum = sum + arr[i]
for j in range(0, len(arr1)):
	print(sum - arr[arr1[j] - 1])


n = int(input())
q = [int(x) for x in input().split()]
m = int(input())
c = [int(x) for x in input().split()]
q.sort(reverse=True)
t = sum(q)
for i in range(m):
	print(t - q[c[i] - 1])


from heapq import nlargest
lineCount = 0
n = int(input())
a = [int(x) for x in input().split(' ')]
m = int(input())
q = [int(x) for x in input().split(' ')]
highestCoupon = max(q)
nLargest = nlargest(highestCoupon, a)
aSum = sum(a)
costList = []
for coupon in q:
	costList.append(aSum - nLargest[coupon - 1])
for cost in costList:
	print(cost)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
m = int(input())
brr = list(map(int, input().split()))
pre = [0] * n
for i in range(n):
	pre[i] = pre[i - 1] + arr[i]
for i in range(m):
	if brr[i] == n:
		print(pre[n - 1] - pre[0])
	else:
		print(pre[n - brr[i] - 1] + pre[n - 1] - pre[n - 1 - brr[i] + 1])


import sys
I = sys.stdin.readline
n = int(I())
a = list(map(int, I().split()))
m = int(I())
q = list(map(int, I().split()))
a.sort()
prefix_sum = [a[0]]
suffix_sum = [a[-1]]
for i in a[1:]:
	prefix_sum.append(prefix_sum[-1] + i)
for i in range(n - 2, -1, -1):
	suffix_sum.append(suffix_sum[-1] + a[i])
suffix_sum.reverse()
for i in q:
	if n - i - 1 < 0:
		ans = suffix_sum[n - i + 1]
	else:
		ans = suffix_sum[n - i + 1] + prefix_sum[n - i - 1]
	print(ans)


n = int(input())
a = list(map(int, input().split(' ')))
m = int(input())
q = list(map(int, input().split(' ')))
a = sorted(a)
soma = sum(a)
for i in range(m):
	k = q[i]
	print(soma - a[-k])


N = int(input().strip())
nums = [int(i) for i in input().strip().split()]
M = int(input().strip())
coupons = [int(i) for i in input().strip().split()]
nums.sort(reverse=True)
the_sum = sum(nums)
for i in range(M):
	print(the_sum - nums[coupons[i] - 1])


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
a.sort()
s = 0
for i in a:
	s += i
for i in b:
	print(s - a[n - i])


n = int(input())
l1 = list(map(int, input().split()))
l1.sort()
sum1 = 0
for i in range(n):
	sum1 = sum1 + l1[i]
m = int(input())
l2 = list(map(int, input().split()))
for i in range(m):
	x = l2[i]
	y = sum1
	y = y - l1[n - x]
	print(y)


input()
Bars = sorted([int(i) for i in input().split()])
S = sum(Bars)
input()
for Coupon in [int(i) for i in input().split()]:
	print(S - Bars[-Coupon])


def main():
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	q = list(map(int, input().split()))
	a.sort(reverse=True)
	add = sum(a)
	for i in range(m):
		print(add - a[q[i] - 1])
	return
main()


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
mod = 10 ** 9 + 7
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, adj, s):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	max_so_far = -sys.maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0, size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i + 1
	return (max_so_far, start, end)

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] >= arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def solve():
	n = int(input())
	arr = sorted(list_input(), reverse=True)
	summ = sum(arr)
	int(input())
	for q in list_input():
		print(summ - arr[q - 1])
t = 1
for _ in range(t):
	solve()


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
b = [int(i) for i in input().split()]
a = sorted(a)[::-1]
d = sum(a)
for i in range(0, len(b)):
	print(d - a[b[i] - 1])


a = int(input())
A = list(map(int, input().split()))
b = int(input())
B = list(map(int, input().split()))
num = sum(A)
A.sort(reverse=True)
for elem in B:
	print(num - A[elem - 1])


n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
m = int(input())
q = [int(x) for x in input().split()]
s = sum(a)
for i in range(m):
	ans = s - a[n - q[i]]
	print(ans)


n = int(input())
a = [int(i) for i in input().strip().split(' ')]
m = int(input())
q = [int(i) for i in input().strip().split(' ')]
a.sort()
s = sum(a)
for i in q:
	print(s - a[-1 * i])


(n, l) = (int(input()), sorted([*map(int, input().split())])[::-1])
(s, n) = (sum(l), int(input()))
for i in [*map(int, input().split())]:
	print(s - l[i - 1])


import sys
from collections import Counter

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip('\n')
n = int(input())
l = get_array()
m = int(input())
s = get_array()
l.sort()
o = sum(l)
for i in s:
	print(o - l[-i])


n = input()
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
l1.sort()
asn = sum(l1)
for i in range(m):
	print(asn - l1[-l2[i]])


n = int(input())
ns = list(map(int, input().split(' ')))
m = int(input())
ms = list(map(int, input().split(' ')))
l = sorted(ns)
lsum = sum(ns)
for i in range(m):
	print(lsum - l[n - ms[i]])


chocs = int(input())
chm = list(map(int, input().split()))
k = int(input())
km = list(map(int, input().split()))
chm.sort()
s = sum(chm)
for i in range(k):
	print(s - chm[chocs - km[i]])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort(reverse=True)
pref = [0]
for i in range(n):
	pref.append(pref[i] + a[i])
for elem in q:
	ans = 0
	ans += pref[elem - 1]
	ans += pref[-1] - pref[elem]
	print(ans)


sobar = int(input())
bars = list(map(int, input().split()))
clone_bars = bars
socu = int(input())
coupons = list(map(int, input().split()))
clone_bars.sort()
clone_bars.reverse()
tong = sum(bars)
for i in coupons:
	print(tong - clone_bars[i - 1])


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
a.sort()
big = sum(a)
a = a[::-1]
for i in q:
	print(big - a[i - 1])


n = int(input())
A = list(map(int, input().split()))
A.sort()
s = sum(A)
k = int(input())
B = list(map(int, input().split()))
for i in range(k):
	print(s - A[n - B[i]])


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
bars = sorted(get_int_list(), reverse=True)
m = get_int()
coupn = get_int_list()
ans = [0] * m
prefix = [0] * n
prefix[0] = bars[0]
for i in range(1, n):
	prefix[i] = prefix[i - 1] + bars[i]
s = prefix[-1]
for i in range(m):
	index = coupn[i] - 1
	temp = prefix[index]
	ans[i] = temp + s - temp - bars[index]
print('\n'.join(map(str, ans)))


n = input()
costs = list(map(int, input().strip().split()))
m = input()
coupon = list(map(int, input().strip().split()))
costs.sort()
ans = 0
for i in costs:
	ans += i
for i in coupon:
	print(ans - costs[-i])


chocolate_bars = int(input())
chocolate_prices = [int(x) for x in input().split()]
coupons = int(input())
cupon_values = [int(x) for x in input().split()]
full_price = sum(chocolate_prices)
chocolate_prices.sort()
for d in cupon_values:
	price_discount = chocolate_prices[-d]
	print(full_price - price_discount)


n = int(input())
arr1 = list(map(int, input().split()))
m = int(input())
arr2 = list(map(int, input().split()))
arr1.sort(reverse=True)
s = sum(arr1)
for i in arr2:
	print(s - arr1[i - 1])


temp = input()
p = list(map(int, input().split()))
p.sort()
sum = 0
for i in p:
	sum += i
temp2 = input()
c = list(map(int, input().split()))
for i in range(0, len(c)):
	print(sum - p[len(p) - c[i]])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort(reverse=True)
ss = sum(a)
for i in q:
	ans = ss - a[i - 1]
	print(ans)


n = int(input())
a = [int(s) for s in input().split(' ')]
m = int(input())
q = [int(s) for s in input().split(' ')]
a.sort(reverse=True)
sm = sum(a)
for qi in q:
	print(sm - a[qi - 1])


n = int(input())
L = [0] + sorted(list(map(int, input().split())))
for k in range(1, n + 1):
	L[k] = L[k] + L[k - 1]
m = int(input())
for k in map(int, input().split()):
	print(L[n - k] + L[-1] - L[n - k + 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
a.reverse()
for i in range(1, n):
	a[i] += a[i - 1]
for i in range(0, m):
	print(a[b[i] - 2] + a[n - 1] - a[b[i] - 1])


R = lambda : map(int, input().split())
(n,) = R()
arr = sorted(R(), reverse=True)
(m,) = R()
a = list(R())
val_sum = sum(arr)
for val in a:
	print(val_sum - arr[val - 1])


n = int(input())
a = list(map(int, input().strip().split()))
m = int(input())
q = list(map(int, input().strip().split()))
a.sort()
s = sum(a)
for d in q:
	print(s - a[n - d])


(n, price) = (int(input()), sorted(list(map(int, input().split())), reverse=True))
(m, coupon) = (int(input()), list(map(int, input().split())))
total = sum(price)
for i in coupon:
	print(total - price[i - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a)
for i in b:
	print(s - a[i - 1])
exit(0)


n = int(input())
barlist = [int(x) for x in input().split()]
barlist.sort(reverse=True)
barsum = sum(barlist)
m = int(input())
couponlist = [int(x) for x in input().split()]
for c in couponlist:
	print(barsum - barlist[c - 1])


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
pref = [0] * (len(arr) + 1)
for i in range(1, len(arr) + 1):
	pref[i] = pref[i - 1] + arr[i - 1]
ss = sum(arr)
for i in range(m):
	print(ss - arr[q[i] - 1])


n = int(input())
lst1 = list(map(int, input().split()))
m = int(input())
lst2 = list(map(int, input().split()))
lst1.sort()
k = sum(lst1)
for i in range(m):
	print(k - lst1[-lst2[i]])


n = int(input())
x = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
sum_x = sum(x)
x.sort()
for j in range(m):
	print(sum_x - x[-q[j]])


n = int(input())
mas = list(map(int, input().split()))
m = int(input())
kup = list(map(int, input().split()))
mas.sort()
mas.reverse()
s = sum(mas)
for i in kup:
	print(s - mas[i - 1])


n = int(input())
x = [*map(int, input().split())]
m = int(input())
y = [*map(int, input().split())]
a = sum(x)
x.sort()
for i in y:
	print(a - x[-i])


ch = int(input())
costs = [int(i) for i in input().split()]
num = int(input())
coupons = [int(i) for i in input().split()]
costs.sort()
costs = list(reversed(costs))
const = sum(costs)
for i in coupons:
	print(const - costs[i - 1])


n = int(input())
inp = input()
a = [int(ele) for ele in inp.split()]
m = int(input())
inp1 = input()
q = [int(ele) for ele in inp1.split()]
sol = []
a.sort()
a.reverse()
summ = sum(a)
for i in range(m):
	tot = 0
	free = q[i]
	tot = summ - a[free - 1]
	sol.append(tot)
for ele in sol:
	print(ele)


n = int(input())
g = [int(g) for g in input().split()]
x1 = sum(g)
g.sort()
m = int(input())
g1 = [int(k) for k in input().split()]
for i in g1:
	print(x1 - g[-i])


n = int(input())
l = list(map(int, input().split()))
q = int(input())
k = list(map(int, input().split()))
l.sort()
l.reverse()
r = sum(l)
for i in range(q):
	print(r - l[k[i] - 1])


n = int(input())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
a.sort()
a = a[::-1]
s = 0
for i in a:
	s += i
for i in range(k):
	print(s - a[b[i] - 1])


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
q = [int(i) for i in input().split()]
a = sorted(a)[::-1]
s = sum(a)
for i in range(m):
	print(s - a[q[i] - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a = sorted(a, reverse=True)
s = sum(a)
dic = {}
for i in range(2, n + 1):
	dic[i] = s - a[i - 1]
for i in q:
	print(dic[i])


n = int(input())
cost = sorted(list(map(int, input().rstrip().split())))
m = int(input())
coupons = list(map(int, input().rstrip().split()))
total = sum(cost)
for i in coupons:
	print(total - cost[-i])


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
qar = list(map(int, input().split()))
arr.sort()
suma = sum(arr)
for i in range(m):
	ans = suma - arr[n - qar[i]]
	print(ans)


n = int(input())
list = [int(i) for i in input().split()]
m = int(input())
temp = [int(i) for i in input().split()]
list.sort()
list = list[::-1]
som = sum(list)
for i in range(0, m):
	print(som - list[temp[i] - 1])


n = int(input())
cl = list(map(int, input().split()))
m = int(input())
cp = list(map(int, input().split()))
cl = sorted(cl)
sm = 0
sl = [0]
for i in range(n):
	sm += cl[i]
	sl.append(sm)
res = []
sm = sum(cl)
for i in range(m):
	t = sm - cl[n - cp[i]]
	res.append(t)
for x in res:
	print(x)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
q1 = [(q[i], i) for i in range(m)]
q1.sort()
a.sort()
pref = [0] * n
pref[0] = a[0]
for i in range(1, n):
	pref[i] = pref[i - 1] + a[i]
q2 = [0] * m
k = max(a)
for i in range(m):
	(x, y) = (q1[i][0], q1[i][1])
	if x == n:
		cost = pref[-1] - pref[0]
	else:
		cost = pref[n - x - 1]
		cost += pref[-1] - pref[n - x]
	q2[y] = cost
for i in range(m):
	print(q2[i])


n = int(input())
if n > 0:
	numbers = [int(i) for i in input().split(' ')]
	numbers.sort()
	sumn = sum(numbers)
	n_coupons = int(input())
	coupons = [int(i) for i in input().split(' ')]
	for i in coupons:
		reverseIndex = len(numbers) - i
		c = sumn - numbers[reverseIndex]
		print(c)
else:
	print('0')


n = int(input())
A = list(map(int, input().split()))
A.sort()
s = sum(A)
m = int(input())
Q = list(map(int, input().split()))
for q in Q:
	print(s - A[n - q])


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
values = list(map(int, input().split()))
arr.sort()
arr = arr[::-1]
ans = sum(arr)
for i in values:
	value = i
	print(ans - arr[value - 1])


n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
m = int(input())
arr2 = list(map(int, input().split()))
sumx = sum(arr)
ansarr = []
for i in range(m):
	ansarr.append(sumx - arr[arr2[i] - 1])
print(*ansarr)


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
m = int(input())
Q = list(map(int, input().split()))
SUM = sum(A)
A.sort()
for q in Q:
	print(SUM - A[-q])


n = int(input())
a = sorted([int(x) for x in input().split()])
q = int(input())
total = sum(a)
b = [int(x) for x in input().split()]
for x in b:
	print(total - a[-x])


def solve(a, q):
	sum = 0
	for elm in a:
		sum += elm
	a.sort(reverse=True)
	for qi in q:
		print(sum - a[qi - 1])
n = int(input())
a = list(map(int, input().split(' ')))
m = int(input())
q = list(map(int, input().split(' ')))
solve(a, q)


n = int(input())
soma = 0
lista = input().split()
lista_preco = [int(i) for i in lista]
soma = sum(lista_preco)
lista_preco.sort()
numCupons = int(input())
lista_cupons = input().split()
lista_cupons = [int(i) for i in lista_cupons]
for c in lista_cupons:
	print(soma - lista_preco[-c])


n = int(input())
a = [x for x in map(int, input().split())]
m = int(input())
q = [x for x in map(int, input().split())]
a.sort(reverse=True)
all = sum(a)
ans = []
for i in range(m):
	ans.append(all - a[q[i] - 1])
print('\n'.join(map(str, ans)))


n = int(input())
z = list(map(int, input().split()))
s = sum(z)
z = sorted(z)[::-1]
q = int(input())
a = list(map(int, input().split()))
for i in range(q):
	print(s - z[a[i] - 1])


input()
array = list(map(int, input().split()))
sum = sum(array)
array = sorted(array)
input()
dis = list(map(int, input().split()))
for i in dis:
	print(sum - array[-i])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort()
b = [0] * n
b[n - 1] = a[n - 1]
for i in range(n - 2, -1, -1):
	b[i] = b[i + 1] + a[i]
l = b[0]
for i in range(m):
	s = b[n - q[i] + 1]
	print(l - b[n - q[i]] + s)


name = 'abcdefghijklmnopqrstuvwxyz'
mapping = {}
for (i, char) in enumerate(name):
	mapping[char] = i
n = int(input())
chocs = [int(i) for i in input().split(' ')]
chocs.sort()
q = int(input())
qarr = [int(i) for i in input().split(' ')]
chocsum = sum(chocs)
for i in qarr:
	print(chocsum - chocs[n - i])


def solve():
	a.sort()
	t = sum(a)
	for i in q:
		print(t - a[-i])

def main():
	global n, a, m, q
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	q = list(map(int, input().split()))
	solve()
main()


n = int(input())
a = list(map(int, input().split(' ')))
a = sorted(a)
arr = [0] * n
arr[0] = a[0]
for i in range(1, len(a)):
	arr[i] = a[i]
	arr[i] += arr[i - 1]
prr = [0] * n
prr[n - 1] = a[n - 1]
for i in range(len(a) - 2, -1, -1):
	prr[i] = a[i]
	prr[i] += prr[i + 1]
m = int(input())
q = list(map(int, input().split(' ')))
for i in range(m):
	check = q[i]
	ans = 0
	if n - check - 1 >= 0:
		ans = arr[n - check - 1]
	ans += prr[n - check + 1]
	print(ans)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
n = mint()
a = list(mints())
a.sort()
s = sum(a)
m = mint()
for i in mints():
	print(s - a[-i])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
x = list(map(int, input().split()))
a.sort(reverse=True)
res = sum(a)
for i in range(m):
	ans = a[x[i] - 1]
	print(res - ans)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
for i in range(1, n, 1):
	l[i] += l[i - 1]
q = int(input())
l1 = list(map(int, input().split()))
for i in range(q):
	ans = 0
	a = l1[i]
	if a - 2 >= 0:
		ans += l[a - 2]
	ans += l[n - 1] - l[a - 1]
	print(ans)


n = int(input())
l = list(map(int, input().split()))
m = int(input())
c = list(map(int, input().split()))
l.sort()
l.reverse()
tot = sum(l)
for i in c:
	print(tot - l[i - 1])


from sys import stdin, stdout

def inp():
	return int(stdin.readline())

def minp():
	return map(int, stdin.readline().rstrip().split())

def linp():
	return list(minp())

def main():
	n = inp()
	l = linp()
	l.sort(reverse=True)
	s = sum(l)
	m = inp()
	ml = linp()
	for i in range(m):
		print(s - l[ml[i] - 1])
main()


import heapq
n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
sum_a = sum(a)
n_sort = max(q)
largest = heapq.nlargest(n_sort, a)
for x in q:
	print(sum_a - largest[x - 1])


n = int(input())
p = [int(x) for x in input().split()]
m = int(input())
l = [int(x) for x in input().split()]
p.sort()
s = sum(p)
for x in l:
	print(s - p[n - x])


cn1 = int(input())
cost = list(map(int, input().rstrip().split()))
cost.sort(reverse=True)
cpnno = int(input())
length = list(map(int, input().rstrip().split()))
summ = sum(cost)
for i in range(cpnno):
	if length[i] == 1:
		print(summ)
	else:
		print(summ - cost[length[i] - 1])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
A.sort(reverse=True)
price = 0
sum = 0
for i in range(n):
	sum += A[i]
for j in range(m):
	ans = sum - A[B[j] - 1]
	print(ans)


n = int(input())
a = input().split(' ')
for (i, a_) in enumerate(a):
	a[i] = int(a_)
m = int(input())
q = input().split(' ')
a.sort()
a_sum = sum(a)
for (i, q_) in enumerate(q):
	print(a_sum - a[-int(q_)])


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
n = int(input())
coup = list(map(int, input().split()))
pri = sum(l)
for i in coup:
	mpri = pri - l[i - 1]
	print(mpri)


n = int(input())
a = sorted(list(map(int, input().split())))
m = int(input())
q = list(map(int, input().split()))
asum = [a[0]]
for i in range(1, n):
	asum.append(asum[-1] + a[i])
for i in q:
	print(asum[-1] - a[n - i])


__author__ = 'NIORLYS'
n = int(input())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
m = int(input())
q = list(map(int, input().split()))
answer = []
for i in range(m):
	answer.append(str(s - a[-q[i]]))
	answer.append('\n')
answer.pop()
print(''.join(answer))


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
arr.sort(reverse=True)
cum_sum = [0 for _ in range(n)]
cum_sum[0] = arr[0]
for i in range(1, len(arr)):
	cum_sum[i] = cum_sum[i - 1] + arr[i]
for c in q:
	if c >= len(arr):
		print(cum_sum[-2])
		continue
	else:
		ans = cum_sum[c - 2] + (cum_sum[-1] - cum_sum[c - 1])
		print(ans)


qtd_choc = int(input())
lista_precos = input().split()
qtd_cupons = int(input())
lista_cupons = input().split()
aux = len(lista_precos)
soma_elementos = 0
output = []
for i in range(aux):
	elemento = int(lista_precos[i])
	lista_precos[i] = elemento
	soma_elementos += elemento
lista_precos.sort()
for i in range(qtd_cupons):
	cupon = int(lista_cupons[i])
	indexElement = aux - cupon
	output.append(soma_elementos - lista_precos[indexElement])
for i in output:
	print(i)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a = sorted(a, key=lambda x: -x)
s = sum(a)
for i in range(m):
	ans = s - a[q[i] - 1]
	print(s - a[q[i] - 1])


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	tc = 0
	if tc:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def solve():
	n = ii()
	a = li()
	m = ii()
	q = li()
	a.sort(reverse=True)
	for i in range(1, n):
		a[i] += a[i - 1]
	for i in q:
		x = i - 1
		print(a[x - 1] + (a[n - 1] - a[x]))
solve()


def f(n, a_arr, m, q_arr):
	a_arr.sort()
	all_sum = sum(a_arr)
	result = []
	for q in q_arr:
		result.append(all_sum - a_arr[-q])
	return ''.join((str(e) + '\n' for e in result))
n = int(input())
a_arr = [*map(int, input().split())]
m = int(input())
q_arr = [*map(int, input().split())]
print(f(n, a_arr, m, q_arr))


t = int(input())
a = list(map(int, input().split()))[:t]
p = int(input())
b = list(map(int, input().split()))[:p]
s = sum(a)
a.sort()
for i in b:
	print(s - a[-i])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
total = 0
for i in range(n):
	total += a[i]
a.sort()
a.reverse()
for i in range(m):
	print(total - a[q[i] - 1])


input()
l = list(map(int, input().split()))
n = int(input())
p = list(map(int, input().split()))
l.sort(reverse=True)
s = sum(l)
for i in range(n):
	print(s - l[p[i] - 1])


n = input()
prices = [int(i) for i in input().split()]
m = input()
coupon_num = [int(i) for i in input().split()]
prices.sort(reverse=True)
total = sum(prices) - prices[coupon_num[0] - 1]
print(total)
index = coupon_num[0] - 1
for i in coupon_num[1:]:
	total = total + prices[index] - prices[i - 1]
	print(total)
	index = i - 1


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi

def binNumber(n, size=4):
	return bin(n)[2:].zfill(size)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())

def par(a):
	print(' '.join(list(map(str, a))))

def tdl(outerListSize, innerListSize, defaultValue=0):
	return [[defaultValue] * innerListSize for i in range(outerListSize)]

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)
n = ini()
a = iar()
a.sort()
m = ini()
ma = iar()
s = sum(a)
for i in ma:
	print(s - a[n - i])


n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
sum_a = sum(a)
m = int(input())
q = list(map(int, input().split(' ')))
for i in q:
	answer = sum_a - a[n - i]
	print(answer)


numeroBarras = int(input())
barrasLista = [int(x) for x in input().split()]
quantidadeCupom = int(input())
cupomLista = [int(x) for x in input().split()]
somaPreco = sum(barrasLista)
barrasLista.sort(reverse=True)
for i in range(quantidadeCupom):
	a = barrasLista[cupomLista[i] - 1]
	soma = somaPreco - a
	print(soma)


from sys import exit, setrecursionlimit
setrecursionlimit(10 ** 6)
inn = lambda : input().strip()
mapp_m1 = lambda : map(lambda x: int(x) - 1, inn().split(' '))
mapp = lambda : map(int, inn().split(' '))
N = int(inn())
cost = list(mapp())
Q = int(inn())
coupon = tuple(mapp())
cost.sort(reverse=True)
summ = sum(cost)
for i in coupon:
	print(summ - cost[i - 1])


def discounts_problem():
	n = int(input())
	a = input().split(' ')
	for (i, _) in enumerate(a):
		a[i] = int(a[i])
	a = sorted(a)
	m = int(input())
	sum = 0
	for i in range(n):
		sum += a[i]
	b = input().split(' ')
	for (i, _) in enumerate(b):
		b[i] = int(b[i])
	for i in range(m):
		print(sum - a[n - b[i]])
	return
discounts_problem()


iin = lambda : int(input())
lin = lambda : list(map(int, input().split()))
n = iin()
a = lin()
a.sort()
sm = sum(a)
m = iin()
ma = lin()
for i in ma:
	print(sm - a[-i])


x = int(input())
s = [int(n) for n in input().split()]
y = int(input())
s.sort()
s = s[::-1]
z = [int(n) for n in input().split()]
m = sum(s)
for n in z:
	print(m - s[n - 1])


n = int(input())
array = input()
A = [int(x) for x in array.split()]
m = int(input())
array = input()
Q = [int(x) for x in array.split()]
total = sum(A)
A.sort()
for q in Q:
	print(total - A[-q])


n = int(input())
numbers = sorted(map(int, input().split()))
m = int(input())
coupons = list(map(int, input().split()))
s = sum(numbers)
for i in coupons:
	print(s - numbers[-i])


TN = 1

def solution():
	n = int(input())
	a = list(map(int, input().split()))
	m = int(input())
	q = list(map(int, input().split()))
	a = sorted(a, reverse=True)
	s = sum(a)
	for i in range(m):
		print(s - a[q[i] - 1])
while TN != 0:
	solution()
	TN -= 1


n = int(input())
a = input().split()
a = [int(i) for i in a]
m = int(input())
q = input().split()
q = [int(i) for i in q]
result = 0
i = 0
while i < n:
	result += a[i]
	i += 1
a.sort(reverse=True)
for i in range(m):
	print(result - a[q[i] - 1])


n = int(input())
cost = list(map(int, input().split()))
cost.sort(reverse=True)
s = sum(cost)
m = int(input())
coupons = list(map(int, input().split()))
for i in coupons:
	print(s - cost[i - 1])


import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
t = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
l.sort(reverse=True)
summ = sum(l)
for i in a:
	z = l[i - 1]
	ans = summ - z
	sys.stdout.write('%d\n' % ans)


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
a.sort(reverse=True)
summation = 0
for i in range(n):
	summation += a[i]
for i in range(m):
	print(summation - a[q[i] - 1])


a = int(input())
b = list(map(int, input().split()))
b.sort()
soma = sum(b)
c = int(input())
d = list(map(int, input().split()))
for i in range(c):
	print(soma - b[d[i] * -1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
m1 = list(map(int, input().split()))
a.sort()
r = sum(a)
for j in range(m):
	print(r - a[-m1[j]])


n = int(input())
listA = list(map(int, input().split()))
listA = sorted(listA, reverse=True)
m = int(input())
sumA = sum(listA)
coupon = list(map(int, input().split()))
for c in coupon:
	print(sumA - listA[c - 1])


input()
ns = sorted((int(x) for x in input().split()))
s = sum(ns)
input()
ms = [int(x) for x in input().split()]
for m in ms:
	print(s - ns[-m])


n = int(input())
bars = map(int, input().split())
m = int(input())
coupons = map(int, input().split())
bars = list(bars)
bars.sort(reverse=True)
s = sum(bars)
for coupon in coupons:
	print(s - bars[coupon - 1])


R = lambda : map(int, input().split())
R()
a = sorted(R())
s = sum(a)
R()
for q in R():
	print(s - a[-q])


n = int(input())
arr = list(map(int, input().split()))
sum = 0
for i in arr:
	sum += i
m = int(input())
query = list(map(int, input().split()))
arr.sort()
for q in range(m):
	print(sum - arr[n - query[q]])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
A.sort(reverse=True)
x = sum(A)
P = list(map(int, input().split()))
for p in P:
	print(x - A[p - 1])


def B():
	n = int(input())
	a = [int(x) for x in input().split()]
	suma = sum(a)
	m = int(input())
	q = [int(x) for x in input().split()]
	a = sorted(a, reverse=True)
	for i in q:
		print(suma - a[i - 1])
B()


input()
x = sorted(list(map(int, input().split())), reverse=True)
(k, p) = (int(input()), list(map(int, input().split())))
sum = sum(x)
for i in range(k):
	print(sum - x[p[i] - 1])


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
l.sort()
x = int(input())
y = list(map(int, input().split()))
for i in y:
	print(s - l[-i])


import heapq
chocolats = []
numChocolats = int(input())
chocolatOptions = input().split(' ')
totalSum = 0
for i in range(0, numChocolats):
	price = int(chocolatOptions[i])
	chocolats += [-price]
	totalSum += price
numCupons = int(input())
couponOptions = input().split(' ')
heapq.heapify(chocolats)
max_coupon = 0
for coupon in couponOptions:
	if int(coupon) > max_coupon:
		max_coupon = int(coupon)
n_largest = heapq.nsmallest(max_coupon, chocolats)
for coupon in couponOptions:
	discountNumber = int(coupon)
	totalCost = 0
	totalCost = totalSum + n_largest[discountNumber - 1]
	print(totalCost)


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
a.sort(reverse=True)
s = sum(a)
for x in q:
	print(s - a[x - 1])


n = int(input())
ar = sorted(list(map(int, input().split())))
r = sum(ar)
m = int(input())
br = list(map(int, input().split()))
for i in br:
	print(r - ar[-i])


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
nb = RI()
cost = sorted(RMI(), reverse=True)
sums = sum(cost)
nb_query = RI()
queries = RMI()
for i in queries:
	print(sums - cost[i - 1])


n = int(input())
a = sorted(map(int, input().split()), reverse=True)
m = int(input())
q = list(map(int, input().split()))
sum_a = sum(a)
for i in range(m):
	qi = q[i]
	print(sum_a - a[qi - 1])


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort(reverse=True)
s = sum(arr)
m = int(input())
brr = [int(i) for i in input().split()]
for i in brr:
	print(s - arr[i - 1])


n = int(input())
li1 = list(map(int, input().split()))
li1.sort()
li1.reverse()
pee = sum(li1)
m = int(input())
lim = list(map(int, input().split()))
for i in lim:
	print(pee - li1[i - 1])


numChocolates = int(input())
palavra = str(input())
numCupons = int(input())
palavra2 = str(input())
chocolates = palavra.split(' ')
cupons = palavra2.split(' ')
valores = [int(val) for val in chocolates]
valores.sort()
total = sum(valores)
for i in range(numCupons):
	cupom = int(cupons[i])
	pos = numChocolates - cupom
	print(total - valores[pos])


def main():
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	m = int(input())
	q = [int(i) for i in input().split()]
	pref = [0]
	for i in range(n):
		pref.append(pref[-1] + a[i])
	for i in range(m):
		print(pref[n] - pref[n - q[i] + 1] + pref[n - q[i]])
main()


n = int(input())
arr = list(map(int, input().split()))
m = int(input())
coupon = list(map(int, input().split()))
arr.sort(reverse=True)
sumation = sum(arr)
for i in range(m):
	val = arr[coupon[i] - 1]
	print(sumation - val)


import sys
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a)
for i in range(0, m):
	d = s - a[b[i] - 1]
	print(d)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort(reverse=True)
mi = min(a)
s = sum(a)
for i in q:
	print(s - a[i - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
c = sum(a)
for i in b:
	print(c - a[len(a) - i])


n = int(input())
a = [int(s) for s in input().split()]
m = int(input())
q = [int(s) for s in input().split()]
total = sum(a)
a.sort(reverse=True)
output = []
for k in q:
	output.append(total - a[k - 1])
print('\n'.join((str(x) for x in output)))


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
m = int(input())
s = list(map(int, input().split()))
sum1 = sum(a)
for q in range(m):
	print(sum1 - a[s[q] - 1])


n = int(input())
a = sorted(map(int, input().split(' ')), reverse=True)
m = int(input())
q = map(int, input().split(' '))

def calc(n, a, m, q):
	summ = sum(a)
	for i in q:
		print(summ - a[i - 1])
calc(n, a, m, q)


n = int(input())
l = sorted(list(map(int, input().split())))
c = sum(l)
m = int(input())
k = list(map(int, input().split()))
for x in k:
	print(c - l[-x])


n = int(input())
a = input()
a = a.split(' ')
sum = 0
for i in range(n):
	a[i] = int(a[i])
	sum += a[i]
m = int(input())
mn = 1000000
b = input()
b = b.split(' ')
for i in range(m):
	b[i] = int(b[i])
a.sort()
a.reverse()
mn -= 1
for i in range(m):
	print(sum - a[b[i] - 1])


numBars = int(input())
prices = input()
arrP = prices.split()
arrPrices = []
for cur in range(0, len(arrP)):
	arrPrices.append(int(arrP[cur]))
numCoupons = int(input())
coupons = input()
arrC = coupons.split()

def sum(array):
	sum = 0
	for cur in range(0, len(array)):
		sum += array[cur]
	return sum
pricesSum = sum(arrPrices)
arrPrices.sort()
for cur in range(0, len(arrC)):
	offSet = int(arrC[cur])
	result = pricesSum - arrPrices[len(arrPrices) - offSet]
	print(result)


n = int(input())
l = input().split()
li = [int(i) for i in l]
z = sum(li)
li.sort()
m = int(input())
l = input().split()
q = [int(i) for i in l]
for i in q:
	print(z - li[n - i])


import math
import sys
mod = 1000000007
n = int(input())
arr = list(map(int, input().split()))
m = int(input())
brr = list(map(int, input().split()))
arr.sort(reverse=True)
crr = []
sumi = 0
for i in arr:
	sumi += i
	crr.append(sumi)
sumi = 0
drr = [0] * (n + 1)
for j in range(n - 1, -1, -1):
	sumi += arr[j]
	drr[j] = sumi
for k in brr:
	print(crr[k - 2] + drr[k])


n = int(input())
vs = sorted([int(x) for x in input().split(' ')])
s = sum(vs)
c = int(input())
cs = [int(x) for x in input().split(' ')]
for i in range(c):
	print(str(s - vs[n - cs[i]]))


def func(params):
	costs = sorted(params[0])[::-1]
	coupons = params[1]
	m = len(costs)
	n = len(coupons)
	total_cost = sum(costs)
	discounted_price = []
	for i in range(n):
		qi = coupons[i]
		discounted_price.append(total_cost - costs[qi - 1])
	for p in discounted_price:
		print(p)
params = []
n = int(input())
params.append(list(map(int, input().split())))
m = int(input())
params.append(list(map(int, input().split())))
func(params)


n = int(input())
a = input().split()
a = [int(x) for x in a]
m = int(input())
q = input().split()
q = [int(x) for x in q]
a = sorted(a)
total = 0
for i in range(n):
	total += a[i]
for j in range(m):
	print(total - a[-q[j]])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
s1 = sum(a)
b = sorted(a, reverse=True)
for i in range(m):
	s = s1 - b[q[i] - 1]
	print(s)


n = int(input())
choco = [int(x) for x in input().split()]
m = int(input())
kup = [int(x) for x in input().split()]
choco.sort(reverse=True)
summa = sum(choco)
for item in kup:
	print(summa - choco[item - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
total = sum(a)
for i in range(m):
	temp = b[i]
	print(total - a[-temp])


n = int(input())
u = list(map(int, input().split()))
k = int(input())
a = list(map(int, input().split()))
u.sort(reverse=1)
s = sum(u)
for i in range(k):
	print(s - u[a[i] - 1])


from sys import stdin
n = int(stdin.readline())
arr = sorted(list(map(int, stdin.readline().split())), reverse=True)
m = int(stdin.readline())
q = list(map(int, stdin.readline().split()))
s = sum(arr)
for i in range(m):
	print(s - arr[q[i] - 1])


f = input()
a = list(map(int, input().split()))
f = input()
b = list(map(int, input().split()))
a.sort()
sum = 0
for i in a:
	sum += i
for i in b:
	re = a[-i]
	print(sum - re)


n = int(input())
l = sorted(list(map(int, input().split())))[::-1]
s = sum(l)
n2 = int(input())
l2 = list(map(int, input().split()))
for i in l2:
	t = l[i - 1]
	print(s - t)


input()
a = list(sorted(map(int, input().split()), reverse=True))
summ = sum(a)
input()
for x in input().split():
	print(summ - a[int(x) - 1])


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
M = INT()
Q = LIST()
A.sort(reverse=True)
sm = sum(A)
for q in Q:
	print(sm - A[q - 1])


n = int(input())
a = input().split(' ')
sum = 0
for i in range(n):
	t = int(a[i])
	sum += t
	a[i] = t
a.sort()
m = int(input())
q = input().split(' ')
for i in range(m):
	print(sum - a[n - int(q[i])])


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
dgl = lambda : list(map(int, input()))
n = ii()
l = il()
cp = ii()
lcp = il()
l.sort(reverse=True)
l2 = [l[0]]
for i in range(1, n):
	l2.append(l[i] + l2[-1])
for i in lcp:
	print(l2[i - 2] + l2[-1] - l2[i - 1])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
A.sort()
s = sum(A)
for i in B:
	print(s - A[-1 * i])


n = int(input())
a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
m = int(input())
q = input().split()
for k in range(len(q)):
	q[k] = int(q[k])
conta = 0
for elemento in a:
	conta += elemento
a.sort(reverse=True)
for i in range(m):
	print(conta - a[q[i] - 1])


n = int(input())
costs = sorted((int(x) for x in input().split(' ')), reverse=True)
sum_costs = sum(costs)
n_coupons = int(input())
coupons = [int(x) for x in input().split(' ')]
for coupon in coupons:
	print(sum_costs - costs[coupon - 1])


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
(n, cost, m, coupon) = (int(input()), ll(), int(input()), ll())
cost.sort()
s = sum(cost)
for v in coupon:
	print(s - cost[-v])


import sys, math
data = sys.stdin.readlines()
n = int(data[0])
ais = list(map(int, data[1].strip().split()))
m = int(data[2])
qis = list(map(int, data[3].strip().split()))
ais = sorted(ais)
sums = sum(ais)
for i in range(m):
	print(sums - ais[-qis[i]])


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
f = sum(l)
m = int(input())
j = list(map(int, input().split()))
for i in range(m):
	print(f - l[j[i] - 1])


n = int(input())
a = list(map(int, input().split()))
m = int(input())
q = list(map(int, input().split()))
a.sort()
soma = 0
for i in range(n):
	soma += a[i]
for i in range(m):
	print(soma - a[n - q[i]])


n = int(input())
prices = list(map(int, input().split()))
number_of_coupons = int(input())
prices.sort(reverse=True)
total = sum(prices)
candies = list(map(int, input().split()))
for i in range(number_of_coupons):
	position = candies[i] - 1
	answer = total - int(prices[position])
	print(answer)