Problem:
 Score : 300 points    Problem Statement There are 3N participants in AtCoder Group Contest .
The strength of the i -th participant is represented by an integer a_i .
They will form N teams, each consisting of three participants.
No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members.
For example, a team of participants of strength 1 , 5 , 2 has a strength 2 , and a team of three participants of strength 3 , 2 , 3 has a strength 3 .  Find the maximum possible sum of the strengths of N teams.      Constraints  1 ≤ N ≤ 10^5  1 ≤ a_i ≤ 10^{9}  a_i are integers.         Input Input is given from Standard Input in the following format:  N  a_1  a_2  ...  a_{3N}       Output Print the answer.        Sample Input 1 2
5 2 8 5 1 5      Sample Output 1 10  The following is one formation of teams that maximizes the sum of the strengths of teams:   Team 1 : consists of the first, fourth and fifth participants.  Team 2 : consists of the second, third and sixth participants.        Sample Input 2 10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000      Sample Output 2 10000000000  The sum of the strengths can be quite large.

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)[::-1]
ans = sum(a[1:2*n:2])
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n):
    ans += a[-2-2*i]
print(ans)

Solution (Python):

import sys
input=sys.stdin.readline
import numpy as np

def main():
    numbers=[]
    dp=[]
    n = int(input())
    numbers=np.array(list(map(int,input().split())),dtype=int)
    numbers.sort()
    print(numbers[n::2].sum())

if __name__=="__main__":
    main()

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))

ans = 0
for i in range(n):
    ans += a[3*n-2-i*2]

print(ans)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))

a.sort()

ans = a[N:]
ans = ans[::2]
print(sum(ans))

Solution (Python):
N = int(input())

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

a = sorted(a, reverse=True)



SUM = 0

for i in range(1, N*2, 2):
    
    SUM = SUM + a[i]

print(SUM)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.sort()
print(sum(A[N::2]))

Solution (Python):
N = int(input())
n = list(map(int,input().split()))
n = sorted(n,reverse=True)
print(sum(n[1:2*N:2]))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
ans = 0
for i in range(1, 2 * N, 2):
  ans += A[i]
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
answer = 0
for i in range(N):
  answer += A[1+2*i]
print(answer)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum([a[i*2+1] for i in range(n)]))

Solution (Python):



def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    ans = sum([A[i] for i in range(3*N-2, N-1, -2)])

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[0+1:N*2+1:2]))

Solution (Python):
n = int(input()); a = list(map(int, input().split()))
a.sort(); x = 0
for i in range(n, 3*n-1, 2): x += a[i]
print(x)

Solution (Python):
from collections import deque

def main():
    N = int(input())
    a = list(map(int, input().split()))
    a.sort()
    a = deque(a)
    ans = 0
    for i in range(N):
        a.pop()
        ans += a.pop()
        a.popleft()
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[1:2*n:2]))

Solution (Python):
n = int(input())
a_l = list(map(int, input().split()))
a_l = sorted(a_l)
ans = sum([ a for a in a_l[n::2]])
print(ans)

Solution (Python):
N = int(input())

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

A_sorted = sorted(A, reverse = True)

strength = 0

for i in range(N):
    strength += A_sorted[2*i+1]

print(strength)

Solution (Python):
N,*a = map(int,open(0).read().split())

a = sorted(a)
ans = 0
for i in range(N):
  ans += a[-2-2*i]
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
i = 1
n = 1
cnt = 0
while 2*i <= 2*N:
    cnt += A[n]
    i += 1
    n += 2
    
print(cnt)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = sorted(list(map(int, input().split())))

ans = 0
for i in range(n):
    ans += a[(3 * n) - (2*i + 2)]

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
r = 0
for i in range(n):
    r += a[2*i+1]
print(r)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
r = 0
for i in range(n):
    r += a[2*i+1]
print(r)

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
A.sort()
print(sum(A[n::2]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n, 3*n, 2):
    ans+=a[i]
print(ans)

Solution (Python):




def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    a_list = [int(x) for x in input().rstrip().split(" ")]
    a_list.sort()

    print(sum([a for i, a in enumerate(a_list[n:]) if i % 2 == 0]))


if __name__ == "__main__":
    resolve()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

cnt = 0
a.sort(reverse=True)

for i in range(1, 2*N, 2):
    cnt += a[i]

print(cnt)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)
ans = 0
for i in range(N):
    ans += a[2*i + 1]
print(ans)

Solution (Python):
n = int(input())
al = list(map(int, input().split()))
al.sort(reverse=True)
ans = 0
for i in range(n):
    ans += al[2*i+1]
print(ans)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))
   
ans = a[-2*n :: 2]
print(sum(ans))

Solution (Python):
N = int(input(' '))
A = input().split(' ')
A = [int(A[i]) for i in range(3*N)]
A = sorted(A, reverse=True)
STG = 0
for i in range(2*N):
  if not i%2==0:
    STG += A[i]
print(STG)

Solution (Python):
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort(reverse=True)
    ans = sum([A[i] for i in range(2 * N) if i % 2 == 1])
    print(ans)

if __name__ == "__main__":
    solve()

Solution (Python):
import sys
n = int(sys.stdin.readline())
a = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
a.sort(reverse=True)
ans = 0
for i in range(n):
    ans += a[2*i+1]
print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

ans = 0
a.sort(reverse = True)
for i in range(1, 2 * N, 2):
  ans += a[i]

print(ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))

a.sort()
a.reverse()

A=a[1:(2*N):2]

print(sum(A))

Solution (Python):


N = int(input())
a = sorted(list(map(int, input().split())))

ans = 0
for i in range(0, 2*N, 2):
    ans += a[i+N]

print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
lb=0
ub=3*n-1
ans=0
for i in range(n):
  lb+=1
  ub-=1
  ans+=a[ub]
  ub-=1
print(ans)

Solution (Python):
n = int(input())
a = sorted(map(int,input().split()))[::-1]
print(sum(a[1:2*n:2]))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse = True)

sum = 0
for i in range(1, N+1):
    sum += a[2 * i - 1]
print(sum)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = 0
for i in range(n):
    ans += a[-2*(i+1)]

print(ans)

Solution (Python):



def main():
    n = int(input())
    li = list(map(int, input().split()))
    li.sort(reverse=True)
    ans = 0
    for i in range(n):
        ans += li[i * 2 + 1]
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[1:N*2:2]))

Solution (Python):
def agc012a_atCoder_group_contest():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    total = 0
    for i in range(n):
        a.pop()
        total += a.pop()
    print(total)

agc012a_atCoder_group_contest()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
s=0
for i in range(1,2*N,2):
    s+=a[i]
print(s)

Solution (Python):



def main():
    N, *A = map(int, open(0).read().split())
    A.sort()
    print(sum(A[-2 : -2 * N - 1 : -2]))


main()

Solution (Python):
N = int(input())
power_list = sorted(list(map(int, input().split())), reverse=True)

power = 0
for i in range(N):
  power += power_list[2*i+1]

print(power)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort()
sum = 0
for i in range(N):
    sum += a[N+2*i]
print(sum)

Solution (Python):
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

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

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

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    a = list(mi())

    a.sort(reverse=True)

    print(sum(a[1::2][:N]))

    

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(sum(a[n:-1:2]))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
b=a[n:-1:2]
print(sum(b))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

a.sort()
a.reverse()

ans=0
cnt=0

for i in range(len(a)):
  if i%2==1:
    ans+=a[i]
    cnt+=1

  if cnt==n:
    break

print(ans)

Solution (Python):
N = int(input())
As = list(map(int, input().split()))

As.sort(reverse=True)

rlt = 0

for i in range(N):
  rlt += As[2*i+1]
  
print(rlt)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]

print(sum([a[2*i+1] for i in range(n)]))

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
s=0
k=n
for i in range(1,3*n,2):
    s+=l[i]
    k-=1
    if(k==0):
        break
print(s)

Solution (Python):

N = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse = True)
a = a[1:-N:2]
print(sum(a))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
sum = 0
for i in range(n):
    sum = sum + a[i*2+1]
print(sum)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
ans = sum(a[1:2 * n:2])
print(ans)

Solution (Python):
N = int(input())
a = sorted([int(x) for x in input().split()], reverse=True)

ans = 0
for i in range(N):
    ans += a[2 * i + 1]

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))

a.sort(reverse = True)
a_center = [a[i] for i in range(2*n) if i%2==1]

print(sum(a_center))

Solution (Python):
N = int(input())
a = sorted(list(map(int, input().split())))
a2 = a[N:]
ans = 0
for i in range(0, 2*N, 2):
    ans += a2[i]
print(ans)

Solution (Python):
n = int(input())
l = sorted(list(map(int, input().split())),reverse=True)
print(sum(l[1:len(l)-n:2]))

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
a=list(map(int,input().split()))
a.sort()
print(sum(a[N::2]))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

answer = 0
for i in (range(1, N+1)):
  answer += A[i*2 - 1]

print(str(answer))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

a.sort()
ans = 0

for i in range(-2, -2 * N - 1, -2):
    ans += a[i]
    

print(ans)

Solution (Python):
n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)


ans = 0
for i in range(1, 2*n+1, 2):
  ans += A[i]
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
a.sort(reverse=True)
for i in range(n):
    ans += a[2*i+1]

print(ans)

Solution (Python):
n = int(input()) 
A = list(map(int,input().split())) 
A.sort(reverse = True)
ans = 0 
for i in range(n):
    ans += A[2*i+1]
print(ans)

Solution (Python):
n = int(input())
a = [int(an) for an in input().split()]
a.sort(reverse=True)
print(sum([a[i*2+1] for i in range(n)]))

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
ans = 0
a = sorted(a)
for i in range(N):
    ans += a[-2 - 2 * i]
print(ans)

Solution (Python):




import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
5 2 8 5 1 5"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000"""
        output = """10000000000"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for i in range(N):
        a.pop()
        ans += a.pop()
    print(ans)


if __name__ == "__main__":
    
    resolve()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse = True)
list = []

for i, j in enumerate(a):
    if i % 2 == 1:
        list.append(j)

answer = sum(list[0 : n])

print(answer)

Solution (Python):
N = int(input())
a = sorted(map(int,input().split()))
print(sum(a[N:3*N:2]))

Solution (Python):
def main():
	N = int(input())
	a = list(map(int, input().split()))

	a.sort()

	print(sum(a[N: 3 * N: 2]))


  
if __name__ == "__main__":
  	main()

Solution (Python):
n=int(input());print(sum(sorted(map(int,input().split()))[n::2]))

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
print(sum(a[1:2*N:2]))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum([a[2*i+1] for i in range(N)]))

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))
A.sort()

start = 0
end = (3 * N) - 1

ans = 0
while True:
    end -= 1
    ans += A[end]
    start += 1
    end -= 1
    if start > end:
        break

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = 0
for i in range(n):
    ans += a[2 * i + 1]
print(ans)

Solution (Python):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort(reverse=True)

    ans = 0
    for i in range(1, 2*N, 2):
        ans += A[i]

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort() 
A = A[N:]
ans = 0
for i in range(0,2*N,2):
  ans += A[i]
print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

a.sort()

a_1 = []
for i in range(N,3*N):
  a_1.append(a[i])

P = []
for i in range(2*N):
  if i%2 == 0:
    P.append(a_1[i])
    
print(sum(P))

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=1)

ans=0
for i in range(n):
    ans += l[1+2*i]

print(ans)

Solution (Python):
n = int(input())
lis = list(map(int, input().split()))

lis  =sorted(lis)

t1 = sum(lis[n:2*n])


nlis = lis[::-1]

t2 = 0
for i in nlis[1:2*n:2]:
    t2 += i


print(max(t1, t2))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(sum(a[n:len(a):2]))

Solution (Python):
N = int(input())
a = sorted(list(map(int, input().split())))[::-1]
print(sum(a[1::2][:N]))

Solution (Python):
N = int(input())
a_list = [int(e) for e in input().split()]
a_list.sort(reverse=True)
a_list = [0] + a_list 
ans_list= list()

for i in range(1,len(a_list)):
    if i%2 == 0:
        ans_list.append(a_list[i])
        if len(ans_list) == N:
            print(sum(ans_list))
            break

Solution (Python):

N = int(input())
an = list(map(int,input().split()))

lists = [[] for _ in range(N)]
an.sort(reverse=True)

for k in range(N):
    lists[k].append(an[2*k])
    lists[k].append(an[2*k+1])
                    
for i in range(N):
    lists[i].append(an[2*N-1+i])

sasa = 0
for j in range(N):
    sasa += lists[j][1]
print(sasa)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(sum(a[n::2]))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A.sort()

ans = 0

for i in range(N):
    ans += A[N + 2 * i]

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
sum=0
for i in range(2*N):
    if i%2==1:
        sum+=A[i]

print(sum)

Solution (Python):
N = int(input())
A = sorted(list(map(int, input().split())))[::-1]

ans = 0
for i, a in enumerate(A[: - N]):
  if i % 2 == 1:
    ans += a
    
print(ans)

Solution (Python):
n=int(input())
a = list(map(int,input().split()))
a.sort()
print(sum(a[n::2]))

Solution (Python):
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  A.sort(reverse=True)
  ans = sum(A[1:2*N:2])
  return ans
print(solve())

Solution (Python):
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  A.sort(reverse=True)
  ans = 0
  for i in range(1,2*N,2):
    ans += A[i]
  return ans
print(solve())

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n, n * 3, 2):
    ans += a[i]
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

aa=a[:2*n]

aaa=aa[1::2]

print(sum(aaa))

Solution (Python):
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    s_a = sorted(A, reverse=True)[:2*n]
    ans = 0
    for i in range(0, 2*n, 2):
        ans += s_a[i+1]
    print(ans)
resolve()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
total = 0
for i in range(n, n * 3, 2):
    total += a[i]
print(total)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
sum=0
for i in range(N):
    sum+=a[2*i+1]
print(sum)

Solution (Python):
n = int(input())
A = sorted(map(int, input().split()), reverse=True)
print(sum(A[1::2][:n]))

Solution (Python):
N = int(input())
participants = sorted([ int(v) for v in input().split(" ") ], reverse=True)




sum = 0
for i in range(0, N):
  
  
  
  
  sum += participants[2*i+1]

print(sum)

Solution (Python):
import heapq
import sys
input = sys.stdin.readline



def main():
    n = int(input())
    A = [-int(i) for i in input().strip().split()]
    heapq.heapify(A)
    ans = 0
    for i in range(2 * n):
        a = heapq.heappop(A)
        if i % 2 == 1:
            ans -= a

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a.sort()
b = a[N:]
print(sum(b[::2]))

Solution (Python):
N = int(input())
l = list(map(int,input().split()))
l.sort(reverse = True )
sum = 0
for i in range(1,2*N,2):
    sum += l[i]
print(sum)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
print(sum(a[1:2*N:2]))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
c = 0

for i in range(N):
    c += a[1 + i*2]
print(c)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))

A = sorted(A)[::-1]
ans = 0

for i in range(1, 2*n, 2):
    ans += A[i]

print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

a=sorted(a)
a=list(reversed(a))
ans=0

for i in range(2*n):
    if i%2==1:
        ans+=a[i]

print(ans)

Solution (Python):
n,*aa=map(int, open(0).read().split())

aa.sort(reverse=True)

print(sum(aa[1::2][:n]))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort()
x = sum(a[N::2])
print(x)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A=sorted(A,reverse=1)
print(sum(A[1:N*2:2]))

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
for i in range((len(A)//3)*2):
    if i%2==1:
        ans+=A[i]
print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ans = 0

l = sorted(a, reverse=True)

for i in range(N):
    ans += l[2*i+1]

print(ans)

Solution (Python):
import heapq

N = int(input())
a = list(map(int, input().split()))

ans = 0
b = list(map(lambda x: x * (-1), a))
heapq.heapify(b)
for _ in range(N):
    heapq.heappop(b)
    ans -= heapq.heappop(b)
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
p = 0

for i in range(n,n*3)[::2]:
    p += a[i]

print(p)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
fact = math.factorial
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
a = l()
a.sort(reverse=True)
ans = 0
for i in range(2*N):
    if i%2 == 1:
        ans += a[i]
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=1)
print(sum(a[1:n*2:2]))

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())))[::-1]
ans=0
for i in range(n):
  ans+=a[i*2+1]
print(ans)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    a.sort()

    print(sum(a[n::2]))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
a.sort()
for i in range(1, n+1) :
    ans += a[-2*i]
print(ans)

Solution (Python):
n = int(input())

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

a.sort(reverse=True)
res = 0
s = 0
for i in range(n):
    res += a[i+1+s]
    s += 1
print(res)

Solution (Python):
n = int(input())
a = list(map(int, input().split(" ")))

a.sort(reverse=True)
sum = 0
for i in range(1, 2 * n, 2):
    sum += a[i]

print(sum)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

ans = sum(a[1:n*2:2])
print(ans)

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
arr = arr[n:]
arr2 = [arr[i] for i in range(len(arr)) if i % 2 == 0]
ans = sum(arr2)
print(ans)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A = A[N:]
t = 0
for i in range(0,2*N,2):
    t += A[i]
print(t)

Solution (Python):
import sys
input = sys.stdin.readline
enum = enumerate

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

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

def main():
	N = int(input())
	vA = linput()
	vA.sort()
	vA.reverse()
	
	res = 0
	res = sum(vA[1:2*N+1:2])
	
	
	print(res)

if __name__ == "__main__":
	main()

Solution (Python):
N = int(input())
A = sorted(map(int, input().split()))[::-1]
I = [1+2*i for i in range(N)]
print(sum(A[i] for i in I))

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
sum_a = 0
for i in range(1,2*n+1,2):
    sum_a += a[i]
print(sum_a)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
res = 0
for i in range(3 * N - 2, 3 * N - 2 - 2 * (N - 1) - 1, -2):
    res += A[i]
print(res)

Solution (Python):
n = int(input())
la = [int(w) for w in input().split()]
la.sort()
ans = 0
for i in range(1, n+1):
    ans += la[-2 * i]
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
b=0
for i in range(2*n):
    if i%2==1:
        b+=a[i]
print(b)

Solution (Python):

n, *a = map(int, open(0).read().split())
a.sort()
print(sum(a[i] for i in range(n, 3 * n, 2)))

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
A.sort()

ans = 0
for i in range(N, 3 * N, 2):
    ans += A[i]

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)
count = 0
for i in range(n, 3*n, 2):
    count += a[i]
print(count)

Solution (Python):
n=int(input())
a_list=[int(i) for i in input().split()]
a_list.sort(reverse=True)
second_list=a_list[1:2*n:2]
print(sum(second_list))

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
from queue import deque
q = deque(a)
ans = 0
for i in range(n):
    v1,v2,v3 = q.popleft(), q.popleft(), q.pop()
    ans += v2
print(ans)

Solution (Python):
N=int(input())
ai=list(map(int,input().split()))
l1=sorted(ai,reverse=True)

l2=l1[1::2]
ans=l2[:N]
print(sum(ans))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)[::-1]
S = 0
for i in range(2*N):
    if i % 2 == 1:
        S += A[i]
print(S)

Solution (Python):

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

ans = 0

for i in range(1, len(a), 2):
    if i >= n * 2:
        break
    ans += a[i]

print(ans)

Solution (Python):
n = int(input())
print(sum(sorted(list(map(int, input().split())))[n::2]))

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
print(sum(li[1:2*n+1:2]))

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
ans=0
for i in range(1,n*2,2):
    ans += li[i]

print(ans)

Solution (Python):
from collections import deque

N=int(input())
A=list(map(int,input().split()))

A.sort()
B=deque(A)

U=0
while B:
    _=B.popleft()
    _=B.pop()
    x=B.pop()
    U+=x

print(U)

Solution (Python):
N = int(input())
a = sorted(map(int, input().split(' ')), reverse=True)

sum_value = 0
for n in range(1,N+1):
    num = a[2*n-1]
    sum_value += num

print(sum_value)

Solution (Python):
n=int(input())

a_list=[int(i) for i in input().split()]
a_list.sort(reverse=True)

b_list=a_list[1:2*n:2]

print(sum(b_list))

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
for i in range(2*N):
  if i%2==1:
    ans+=a[i]
print(ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
S=0
for i in range(2*N):
    if i%2==1:
        S+=a[i]

print(S)

Solution (Python):
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

num = len(a)//3
ans = sum([a[2*x+1] for x in range(num)])
print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
print(sum(a[1:N*2+1:2]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
res = 0
for i in range(1, n * 2, 2):
  res += a[i]
print(res)

Solution (Python):
n,*a=map(int, open(0).read().split())
print(sum(sorted(a)[n:][::2]))
'''
why do people think there is a purpose in life'''

Solution (Python):
n,*a=map(int, open(0).read().split())
print(sum(sorted(a)[n:][::2]))

Solution (Python):
n=int(input())
*a,=map(int,input().split())
a.sort()
a.reverse()
ans=0
for i in range(n):
  ans+=a[i*2+1]
print(ans)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = i()
a = l()
a.sort()
for i, num in enumerate(a[N:]):
    if i % 2 == 0:
        ans += num

print(ans)

Solution (Python):
N = int(input())
a = sorted(list(map(int, input().split())))

total = 0
for i, num in enumerate(a[N:]):
    if i % 2 == 0:
        total += num

print(total)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[1:2*n+1:2]))

Solution (Python):
num = int(input())
a = sorted(list(map(int, input().split())))
print(sum(a[-2:-2 * num - 1:-2]))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)

print(sum(a[1:2*n:2]))

Solution (Python):
def resolve():
    N = int(input())
    A = list(reversed(sorted([int(i) for i in input().split()])))
    sumA = 0
    for i in range(N):
        sumA += A[(2 * i) + 1]
    print(sumA)


resolve()

Solution (Python):
import math

n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
b = [a[2*i+1] for i in range(n)]
print(sum(b))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
ans=0
for i in range(N):
    ans+=A[N+2*i]
 
print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
ans=0
for i in range(N):
    ans+=A[N+2*i]

print(ans)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ans = 0
    for i in range(1,2*n,2):
        ans += a[i]
    print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a_rev = sorted(a)[::-1]
a_rev = a_rev[1::2]
print(sum(a_rev[:N]))

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
c = 0
x = []
for i in range(2*(n+1)):
    if c%2==0:
        c+=1
        continue
    val = l[c]
    x.append(val)
    c+=1
x=x[:-1]
print(sum(x))

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(n,3*n,2):
    ans += a[i]
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)

    

    ans = 0

    for i in range(1, 2 * N, 2):
        ans += A[i]

    
    

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
lis = list(map(int, input().split()))
lis.sort(reverse=True)
lis = lis[1::2]

ans = 0

for i in range(N):
    ans += lis[i]

print(ans)