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.



Sample input:
2
5 2 8 5 1 5


Sample output:
10

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
r = 2 * N
ans = 0
a.sort(reverse=True)
if a[0] > 10**9:
    exit()
a_choiced = a[0:r][1::2]
for i in a_choiced:
    ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

N = int(input()) * 3
a = list(map(int, input().split()))
ans = 0

a = sorted(a, reverse = True)

for i in range(1, int(2.0 / 3.0 * float(N)), 2):
    #print(a[i])
    ans += a[i]

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
import math

#inf = 10**17
#mod = 10**9 + 7

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

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
L.sort()
L=L[::-1]
R=0
for i in range(N):
  R=R+L[2*i+1]
print(R)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
ans = A[1:2 * n + 1:2]
print(sum(ans))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[9]:


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


# In[12]:


a_s = sorted(a, reverse=True)
print(sum(a_s[1:N*2:2]))


# In[ ]:

Submission status: Accepted

Solution code:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N = inp()

a = inlist()
a = sorted(a)
st = 3*N - 1
wk = 0
res = 0
for i in range(N):
    chosen = st - 1
    res += a[chosen]

    wk += 1
    st -= 2

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

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

Submission status: Accepted

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

print(sum([x for i,x in enumerate(sorted(a,reverse=True)[:(n*2)]) if i%2==1]))

Submission status: Accepted

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
print(sum(a[1:2*N:2]))

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n = int(input())
a = sorted(list(map(int, input().split())))
now = -2
ans = 0
for i in range(n):
    ans += a[now]
    now -= 2
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())

a = tuple(map(int,input().split()))
que = deque(sorted(a))

ans = 0
for i in range(n):
  que.popleft()
  que.pop()
  ans+=que.pop()
  
print(ans)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    A.sort(reverse = True)
    ans = 0
    for i in range(N):
        ans += A[2*i+1]
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(sum(A[i] for i in range(1, 2 * N + 1, 2)))

Submission status: Accepted

Solution code:
N = int(input())
A = sorted(list(map(int,input().split())),key=lambda x: -x)[:2*N]
ans = 0
for i in range(1,2*N,2):
    ans += A[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
# 貪欲に上から１つおきにとるのが最大
for i in range(1, n + 1):
    ans += a[-2 * i]
print(ans)

Submission status: Accepted

Solution code:
n, *a_l = map(int, open(0).read().split())
a_l.sort(reverse = True)
ans = 0
for a in a_l[1:2*n:2]:
    ans += a
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
member = sorted(map(int, input().split()))
ans = sum(member[N::2])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
i = 0
ans = 0
j = 3 * n - 2
while i < n:
    ans += a[j]
    i += 1
    j -= 2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
as_ = list(map(int, input().strip().split()))
as_ = sorted(as_, reverse=True)
total = sum([as_[i] for i in range(n * 2) if i % 2 == 1])
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/agc012/tasks/agc012_a
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(groups, eachScore):
    result = 0
    sortEachScore= sorted(eachScore)
    for userNo in range(groups, groups*3, +2):
        result = result + sortEachScore[userNo]
    return result
if __name__ == "__main__":
    N = II()
    AI = LI()
    print("{}".format(solver(N, AI)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import random
n = int(input())
a = list(map(int,input().split()))

#n = 3
#a = [1,2,3,4,5,6,7,8,9]

a = sorted(a,reverse=True)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

a.sort(reverse=True)

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = list(map(int, input().split()))

    A_sorted = sorted(A)[::-1]
    teams = list([] for _ in range(n))
    idx = 0
    count = 0

    for score in A_sorted:
        teams[idx].append(score)
        
        count += 1

        if count == 2:
            if idx == n -1:
                idx = 0
            else:
                idx += 1
            
            count = 0
    
    res = 0

    for team in teams:
        res += team[1]
    
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

A.sort(reverse=True)

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A - AtCoder Group Contest

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)

Submission status: Accepted

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

print(sum(A[n:3*n:2]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

# A - AtCoder Group Contest
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = 0

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

Submission status: Accepted

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

a.sort(reverse=True)

s = 0
for x in range(1, 2*n+1, 2):
    s += a[x]

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
la = list(map(int, input().split()))

la = sorted(la, reverse=True)
# print(la)

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

print(ans)

Submission status: Accepted

Solution code:
# Problem:https://atcoder.jp/contests/agc012/tasks/agc012_a
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


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


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


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


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(groupNumber, scoreList):
    allMenbar = 3 * groupNumber
    scoreList.sort()
#    print(scoreList)
    secondPositioner = scoreList[groupNumber:allMenbar:+2]
#    print(secondPositioner)
    result = sum(secondPositioner)
    # algorithm
    return result


if __name__ == "__main__":
    N = II()
    AI = LI()
    print("{}".format(solver(N, AI)))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    N,=pin()
    A=lispin()
    A.sort()
    #print(A)
    temp=0
    for i in range(N*2):
        t=A.pop()
        if i%2:temp+=t
    print(temp)
#%%submit!
resolve()

Submission status: Accepted

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

ans = sum(A[1:2*N:2])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    l.sort(reverse=True)
    ans=0
    print(sum(l[1:2*n:2]))
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    a=sorted([int(_) for _ in input().split()])[::-1]
    print(sum(a[1:2*N+1:2]))
main()

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc012/tasks/agc012_a

n = int(input())
nums = [int(i) for i in input().split()]
nums.sort()
nums = nums[n:]

ans = 0
for i in range(0, len(nums), 2):
    ans += nums[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

s.sort(reverse = True)

ans = 0

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

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
A = deque(sorted(map(int, input().split())))

def I_forgot_my_friends_birthday_sorry():
    for _ in range(n):
        A.popleft()
        A.pop()
        yield A.pop()

print(sum(I_forgot_my_friends_birthday_sorry()))

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(map(int,input().split()),reverse=True)
ans = 0
t = (n*3)//3
cnt = 0
i = 1 
while cnt<t:
    cnt += 1
    ans += a[i]
    i += 2
print(ans)

Submission status: Accepted

Solution code:
#複数の整数入力を受け付ける関数
def datain(num):

    data = []
    iscnt = True

    while iscnt:
        for val in map(int,input().split()):
            data.append(val)
            if len(data) == num:
                iscnt = False
                break
        
    return data

num = int(input())
data = datain(num*3)
data.sort()
ans = 0

for i in range(num*3-2,num-1,-2):
    #print(i)
    ans += data[i]

#print(data)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/agc012/tasks/agc012_a
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


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


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


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


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(eachPoints):
    result = 0
    menbers = len(eachPoints)
    group = menbers // 3
    eachPoints.sort(reverse=False)
#    print(eachPoints)
    useSkillList = []
    #  最初のグループ個だけカットしたリストを新規作成[0,1,2,3,4,5]->[2,3,4,5]
    for ui in range(group, menbers, +1):
        useSkillList.append(eachPoints[ui])
#    print("UseListOnly {}".format(useSkillList))
    # for pi in range(0, menbers):
    #    if pi // group == 1:
    #        print("Get Position -> {}={}".format(pi, eachPoints[pi]))
    #        result = result + eachPoints[pi]
    # algorithm
    for sum2pos in range(0, len(useSkillList), +2):
        result = useSkillList[sum2pos] + result
    return result


if __name__ == "__main__":
    _ = II()
    AI = LI()
    print("{}".format(solver(AI)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main():
    N, *a = map(int, open(0).read().split())

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


main()

Submission status: Accepted

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

a = sorted(a,reverse=True)
ans = 0
for i in range(n):
    ans += a[2*i+1]
print(ans)

Submission status: Accepted

Solution code:
import collections
n = int(input())
*a, = map(int, input().split())
a.sort()
a = collections.deque(a)
ans = 0
while n:
    a.popleft()
    a.pop()
    ans += a.pop()
    n -= 1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    a_arr = list(map(int,_in[1].split(' ')))
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    a_arr.sort(reverse=True)
    cnt = sum(a_arr[1:2*N:2])
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Asort = sorted(A)

    sumMed = 0
    for i in range(n):
        sumMed += Asort[n + i * 2]

    print(sumMed)

resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

a.sort(reverse=True)

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

Submission status: Accepted

Solution code:
n = int(input())
l = map(int,input().split())

l = sorted(l,reverse=True)

l2 = []

for i in range(1,2*n+1,2):
    l2.append(l[i])
    

print(sum(l2))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
A.sort()
B = A[n:n*2]
C = A[-2:-2-n*2:-2]
D = A[1:n*3+1:3]

ans = max(sum(B), sum(C), sum(D))
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

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

a.sort(reverse=True)


res = 0

cnt = 0
i = 1
while (cnt < len(a)//3)  :
    res += a[i]
    i += 2
    cnt+=1

print(res)

Submission status: Accepted

Solution code:
n = int(input())
a_inputs = sorted([int(i) for i in input().split()])

k_num = len(a_inputs)
#弱い順にソート,最初のk人を一番弱いメンバーとする。
#残りを(k+1,k+2),(k+3,k+4),...(n-1,n)と並べた時のk+1,k+3...n-1の値値を求める

print(sum([a_inputs[i] for i in range(n,k_num,2)]))

Submission status: Accepted

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)

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

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = II()
    aa = MII()
    aa.sort(reverse=True)
    print(sum(aa[1:2*n:2]))
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort()
ans, cnt = 0, 0
for i in range(3 * N - 2, -1, -2):
    cnt += 1
    ans += a[i]
    if(cnt == N): break
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
a=input().split()
a=[int(x) for x in a]
a.sort(reverse=True)
s=0
for i in range(N):
    s+=a[2*i+1]

print(s)

Submission status: Accepted

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

a = sorted(a, reverse=True)

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

print(res)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())  # 文字列または整数(一変数)
    a = list(map(int, input().split()))  # 整数のリスト

    answer = 0
    a.sort(reverse=True)

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


    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = input().split()
a_i = [int(s) for s in a]
a_i.sort(reverse=True)
result = 0
for i in range(1,2 * N,2):
    result += a_i[i]
print(result)

Submission status: Accepted

Solution code:
def main():
    N = int( input())
    A = list( map( int, input().split()))
    A.sort()
    print( sum(A[N::2]))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8
n = int(input())
s = list(map(int, input().split()))
score = sorted(s, reverse=True)
ans = 0

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

print(ans)