conf = 0

num_char = int(eval(input()))

char = list(map(int, input().split()))

char.sort(reverse=True)

count = 0

conf_int = 0

for i in range(num_char):

  if count == 0:

    count = 1

  elif count == 1:

    count = 2

    conf = char[conf_int]

    count_int = 0

    conf_int = 1

  else:

    if count_int == 0 :

      conf += char[conf_int]

      count_int = 1

    else:

      conf += char[conf_int]

      conf_int += 1

      count_int = 0

print(conf)
N = int(eval(input()))



As = sorted(map(int, input().split()), reverse=True)



score = As[0]

counter = 0

index = 1



for i in range(2, N):

  score += As[index]

  if counter == 0:

    counter += 1

  else:

    counter -= 1

    index += 1

    

print(score)







            

         
conf = 0
num_char = int(eval(input()))
char = list(map(int, input().split()))
char.sort(reverse=True)
count = 0
conf_int = 0
for i in range(num_char):
    if count == 0:
        count = 1
    elif count == 1:
        count = 2
        conf = char[conf_int]
        count_int = 0
        conf_int = 1
    else:
        if count_int == 0:
            conf += char[conf_int]
            count_int = 1
        else:
            conf += char[conf_int]
            conf_int += 1
            count_int = 0
print(conf)

N = int(eval(input()))
As = sorted(map(int, input().split()), reverse=True)
score = As[0]
counter = 0
index = 1
for i in range(2, N):
    score += As[index]
    if counter == 0:
        counter += 1
    else:
        counter -= 1
        index += 1
print(score)

-conf = 0 -num_char = int(eval(input())) -char = list(map(int, input().split())) -char.sort(reverse=True) -count = 0 -conf_int = 0 -for i in range(num_char): -    if count == 0: -        count = 1 -    elif count == 1: -        count = 2 -        conf = char[conf_int] -        count_int = 0 -        conf_int = 1 +N = int(eval(input())) +As = sorted(map(int, input().split()), reverse=True) +score = As[0] +counter = 0 +index = 1 +for i in range(2, N): +    score += As[index] +    if counter == 0: +        counter += 1 -        if count_int == 0: -            conf += char[conf_int] -            count_int = 1 -        else: -            conf += char[conf_int] -            conf_int += 1 -            count_int = 0 -print(conf) +        counter -= 1 +        index += 1 +print(score)