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:
def maximumSum(a):
    foo = 0
    n = len(a)/3
    a = sorted(a)
    for i in xrange(n):
        foo += a[n*3-(i+1)*2]
    return foo

def main():
    n = int(raw_input().strip())
    a = [int(x) for x in raw_input().strip().split()]
    print maximumSum(a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
a.sort()
S = 0
for i in range(N):
    S += a[2*i+N]
print(S)

Submission status: Accepted

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

A.sort(reverse=1)
print(sum(A[1:2*N:2]))

Submission status: Accepted

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

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:
N=input()
A=input().split(' ')
l=[]
for i in A:
  l.append(int(i))
l.sort()
l.reverse()
ans=0
for i in range(int(N)):
  ans+=l[2*i+1]
print(ans)

Submission status: Accepted

Solution code:
#bin/usr/env python3

N = int(input())
a = input()
x = 0
b = []

a = a.split()
for i in a:
	b.append(int(i))
b.sort()
for i in range(N):
	c = b[-(2*(i+1))]
	x += int(c)
print(x)

Submission status: Accepted

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

N = int(input())
data = input().split(" ")
a = [int(i) for i in data]
sum = 0
a.sort(reverse=True)

for i in a[1:int(N*2):2]:
    sum += i

print(sum)

Submission status: Accepted

Solution code:
n = int(input())
a_s = input().split()
a_s = [int(a) for a in a_s]

a_s.sort(reverse=True)

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

print(total)

Submission status: Accepted

Solution code:
n = int(input())
xs = [int(x) for x in input().split()]
xs.sort()

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

Submission status: Accepted

Solution code:
# -*- coding: UTF-8 -*-
N = int(input())
d = list(map(int,input().split(" ")))
d.sort(reverse = True)
_ans = []
for i in range(N):
    _ans.append(d[2*i+1])
print(sum(_ans))

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    a_list = list(sorted(list(map(int, input().split()))))
    print(sum([a_list[-i * 2 - 2] for i in range(0, N)]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def group_contest():
	n = int(raw_input())
	a = map(int, raw_input().split(" "))
	a.sort(reverse=True)
	candidates = a[1::2]
	print sum(candidates[:n])

if __name__ == "__main__":
	group_contest()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(sorted(map(int, input().split())))
# N = 10
# A = [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]
# A = sorted(A)
# print(A)

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

    if cnt == N:
        break
print(total)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
sum=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
a = na()

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

print (sum)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
for tmp in range(N, 3*N, 2):
    ans += a[tmp]
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[N+2*i]
print(ans)

Submission status: Accepted

Solution code:
N = input()
arr = map(int, raw_input().split())
arr.sort()
sum = 0
for i in range(3*N-2, N-1, -2):
  sum += arr[i]
print sum

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()
print sum(A[N::2])

Submission status: Accepted

Solution code:
n = int(input())
aa = sorted(map(int, input().split()))
print(sum(x for x, y in zip(*[iter(aa[n:])] * 2)))

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 + 1, 2):
    ans += a[i]

print(ans)

Submission status: Accepted

Solution code:
n = int(raw_input())
ls = map(int, raw_input().split())
ls.sort()
sum = 0
for i in range(n):
    sum += ls[n+i*2]
print sum

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    a_list = get_a_list()

    a_list.sort(reverse=True)

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

    print(sum_second_a)

def get_a_list():
    a_list = []
    strs = input().split()

    for a in strs:
        a_list.append(int(a))

    return a_list


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

N = int(input())
list_s = input().split(' ')
players = [int(d) for d in list_s]

# N = 2
# players = [5, 2, 8, 5, 1, 5]

players.sort()
players = players[::-1]
# print(players)

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

print(sum)

Submission status: Accepted

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

P.sort()
P2 = P[N:]

print(str(sum(P2[::2])))

Submission status: Accepted

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

    a.sort()
    p = 0
    i = N
    while i < N*3:
        p += a[i]
        i += 2
    print(p)

main()

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split(' ')]

a.sort()
res = 0

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

print(res)

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(raw_input())
a = sorted(map(int, raw_input().split()))
print sum([a[i] for i in xrange(3*N-2, N-1, -2)])

Submission status: Accepted

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

ans3=0
for i in range(N):
    ans3 += b[i*2+N]

print(ans3)

Submission status: Accepted

Solution code:
#AGC012A

n=int(raw_input())
a=map(int,raw_input().split())
a=sorted(a)
b=a[n::2]
print sum(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
arr = sorted(map(int, raw_input().split()))

print sum(map(lambda i: arr[n + 2 * i], range(n)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main():

    n = int(raw_input())
    a = map(int,raw_input().split())

    if n <= 0 or n > 10 ** 5:
        return
    for i in a:
        if i <= 0 or i > 10 ** 9:
            return

    a.sort(reverse=True)
    trio_sum = 0

    for i in range(n):
        index = (i * 2) + 1
        trio_sum += a[index]

    return trio_sum

print main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
N = int(input())
a = list(map(int, input().split()))
 
total = 0
a2 = sorted(a, reverse=True)
 
for id in range(N):
	total += a2[2*id+1]
 
print(total)

Submission status: Accepted

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


def max_sum_strength(n, xs):
    ys = sorted(xs, reverse=True)
    res = sum(ys[i] for i in range(1, 2 * n, 2))
    return res


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    res = max_sum_strength(n, xs)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

idx = 1
ans = 0

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

print(ans)

Submission status: Accepted

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

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())
print(sum(sorted(map(int,input().split()))[n::2]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- encoding: utf-8 -*-
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)

Submission status: Accepted

Solution code:
import numpy as np


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

res = 0
for i in range(len(a[N:])):
    if i % 2 == 0:
        res += a[N+i]

print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# problem A

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

def prob_a(n, a):
    ans = 0    
    for i in range(0, 2*n, 2):
        ans += a[i+1]
    return(ans)
    
x = prob_a(n=n, a=a)
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_lines = str(input())
input_lines2 = str(input())

n = int(input_lines)
aAry = input_lines2.split(' ')
aAry = map(int,aAry)
aAry = sorted(aAry)
#print(aAry)

answer1 = 0
for i in range(n):
    answer1 += int(aAry[(-i-1)*2])
'''
answer2 = 0
for i in range(n):
    answer2 += int(aAry[-i-3])

if answer1 >= answer2:
    answer = answer1
else:
    answer = answer2
'''
print(answer1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  1 22:07:55 2017

@author: taichiNakamura
"""
import numpy as np
N = int(input())
# スペース区切りの整数の入力
num = list(map(int, input().split()))

num = np.array(num, dtype="int64")
num.sort()
sum = 0

for i in range(N):
    sum += num[3*N - 2 - i*2]
# 出力
print(sum)

Submission status: Accepted

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

n=int(raw_input().strip())
a=map(int,raw_input().split())
a.sort()
a.reverse()
total=0
for i in range(n):
    total+=a[i*2+1]
print total

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N = int(raw_input())
a = raw_input().split(" ")
output = 0

b = []

for i in a:
    b.append(int(i))

b.sort(reverse=True)

for i in range(N):
    output = output + int(b[2*i+1])

print output

Submission status: Accepted

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

Submission status: Accepted

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

l.sort()
l.reverse()

s = 0

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

print(s)

Submission status: Accepted

Solution code:
n = input()
a = map(int, raw_input().split())
a.sort()
sum = 0
for i in xrange(1, n + 1):
    sum += a[3*n-2*i]
print sum

Submission status: Accepted

Solution code:
n = map(int, raw_input().split())
x = map(int, raw_input().split())
x.sort(reverse = True)
#print x
sum = 0
if n[0]%2==0:
    for i in range(0, n[0]):
        sum = sum +x[i*2+1]
        #print i
elif n[0]%2!=0:
    for i in range(0, (n[0]-1+1)):
        sum = sum +x[i*2+1]
print sum

Submission status: Accepted

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

for num in range(N):
    sum += members[2 * num + 1]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N=input()
As=map(int,raw_input().split())

As.sort(reverse=True)

r=0
for i in xrange(1, len(As)*2/3, 2):

    r+=As[i]
print (r)

Submission status: Accepted

Solution code:
num=input()
numlis=map(int,raw_input().split())

numlis.sort()
numlis.reverse()

ans=0

for i in range(num):
	ans+=numlis[i*2+1]

print ans

Submission status: Accepted

Solution code:
N=int(raw_input())
a=map(int,raw_input().split(' '))

a.sort()
a=a[::-1]

s=sum(a[N:2*N])

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

print max(s,s2)

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:
n = int (input())
a = list(map(int, input().split()))
a.sort()
res = sum(a[n::2])
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())
a = [int(i) for i in input().split()]
nsum = 0
a.sort()
t = [0 for i in range(3*n)]

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

Submission status: Accepted

Solution code:
n = int(input()) # チーム数
a = list(map(int,input().split()))

a.sort()
a.reverse()

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())))
a.sort()
print(a[N:(3*N):2].sum())

Submission status: Accepted

Solution code:
N = int(input())

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

inp.sort()
inp.reverse()

i=0
count=0
ans = 0
while(count<N):
    ans += inp[i+1]
    i += 2
    count += 1

print(ans)

Submission status: Accepted

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

a.sort()
a.reverse()

b = a[1::2]

result = sum(b[:N])

print(result)

Submission status: Accepted

Solution code:
N = int(input())
ais = input().split()
ai = []
for a in ais:
    ai.append(int(a))
ai.sort(reverse=True)
ret = 0
for i,a in enumerate(ai):
    if i > 2 * N:
        break
    if i % 2 == 0:
        continue
    else:
       ret += a
print(ret)

Submission status: Accepted

Solution code:
N = input()
a = sorted(map(int, raw_input().split()))
res = []
for i in range(N):
    res.append(a[-2*i-2])
print sum(res)

Submission status: Accepted

Solution code:
#!/usr/bin/python
import numpy as np

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

a = np.array(sorted(a)[N:])
print (a.reshape(-1, 2).sum(axis=0)[0])

Submission status: Accepted

Solution code:
Nlist = int(input())
alist = [int(x) for x in input().split(" ")]
alist.sort()
sum = 0
for i in range(1,Nlist+1):
    sum += alist[-2*i]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

n = ni()

a = nil()
a.sort()
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

a = sorted(a)
b = a[:]

c = 0
for i in range(n):
	a.pop()
	c += a.pop()

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(raw_input())
N=map(int,raw_input().split())
N.sort()
count=0
for i in range(n,2*n):
	count+=N[i]
res=x=0
for i in range(3*n-2,-1,-2):
	if x==n:
		break
	res+=N[i]
	x+=1
print max(res,count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""AtCoder Grand Contest 012
A - AtCoder Group Contest"""


def main():
    n = int(input())
    inp = list(sorted(map(int, input().split())))
    print(sum(inp[len(inp) - 2 * x - 2] for x in range(n)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(raw_input())

a = map(int, raw_input().split())

ans = 0

k = 0
i = 0

a.sort()

last = 3*n - 2

ans = 0

while k < n:
    ans += a[last]
    last -= 2
    k += 1
    
print ans

Submission status: Accepted

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

    A.sort()

    s = -2
    S = 0
    for i in range(N):
        S += A[s]
        s = s - 2

    print(S)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
num = 3 * int(input())
target = [int(n) for n in input().split(" ")]
target.sort()
third = num // 3
answer = 0
temp = 0
for i in range(third):
    answer += target[num - (2 * (i+1))]
    temp += target[third+i]
#     print(num - (2 * (i+1)))
print(max(answer,temp))

Submission status: Accepted

Solution code:
n=int(raw_input())
a=map(int,raw_input().split())
a.sort(reverse=True)
ans=0
i=1
cnt=0
while cnt<n:
    ans+=a[i]
    cnt+=1
    i+=2
print ans

Submission status: Accepted

Solution code:
#coding=UTF-8


N=int(input())
mozir=input()
hyo=mozir.split(' ')
a=[int(mono) for mono in hyo]

kirei_a=sorted(a,reverse=True)
ans=0

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

print(ans)

Submission status: Accepted

Solution code:
import sys

cin = sys.stdin
# cin = open("in.txt", "r")

N = int(cin.readline())
A = list(map(int, cin.readline().split()))
A.sort()
ans = sum(A[-2:(-2*N-1):-2])


print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

N = n()
A = ln()

A.sort()

upper = A[N:][::-1]
print sum(upper[1::2])

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

Solution code:
N = int(input())
print(sum(sorted(int(x) for x in input().split())[N::2]))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline())
a = map(int, stdin.readline().split())
a.sort()
a.reverse()
print sum(a[1:1+2*n:2])

Submission status: Accepted

Solution code:
# cook your code here
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split())
a.sort()
ans = 0
i = 3*n - 1 
for _ in xrange(n):
    ans += a[i-1]
    i-=2 
print ans

Submission status: Accepted

Solution code:
from sys import stdin, stderr

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort(reverse=True)

    ans = 0
    cnt = 0

    for i in range(3*N):
        if i % 2:
            ans += A[i]
            cnt += 1

            if cnt == N:
                break

    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) 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 main():
    n = I()
    a = sorted(LI(), reverse=True)
    r = 0
    for i in range(n):
        r += a[i*2+1]

    return r



print(main())

Submission status: Accepted

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())
A = list(sorted(A))
s = 0
for i in xrange(N):
    A.pop()
    s += A[-1]
    A.pop()
print s

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[2*i+1]
print(ans)

Submission status: Accepted

Solution code:
def strength(n, people):
	total = 0
	for i in range(n):
		for j in range(2):
			if j == 1:
				total += people[i*2+1]
	return total

# print(strength(2, sorted([5,2,8,5,1,5], reverse=True)))
n = int(input())
people = sorted(list(map(lambda x: int(x), input().split())), reverse=True)
print(strength(n, people))

Submission status: Accepted

Solution code:
# coding: utf-8
num_N = int(input())
l_sto = list(map(int, input().split()))
l_sto.sort(reverse=True)
ans = 0
for i in range(num_N):
    ans += l_sto[i * 2 + 1]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a= [int(x) for x in input().split()]

a.sort()

# 0 to N-1 never use
#
ans = 0
for i in range(N,3*N-1,2):
    ans += a[i]

print(ans)

Submission status: Accepted

Solution code:
n = input()
A = sorted(map(int, raw_input().split()))
ans = 0
for i in xrange(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()
a.reverse()
total = 0
for i in range(N):
    total += a[i*2 + 1]
print(total)

Submission status: Runtime Error

Solution code:
def main():
    N, K = map(int, input().split())
    h = []
    for _ in range(N):
        h.append(int(input()))
    h.sort()
    ans = pow(10, 10)
    for k in range(N-K+1):
        ans = min(ans, abs(h[k]-h[K-1+k]))
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#
# agc012 a
#
 
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(0)
        a.pop()
        ans += a.pop()
    print(ans)
 
 
if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Runtime Error

Solution code:
#
# agc012 a
#

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/3):
        a.pop()
        a.pop(0)
        ans += a.pop()
    print(ans)


if __name__ == "__main__":
    unittest.main()
    # resolve()

Submission status: Runtime Error

Solution code:
N = int(input())
li = list(map(int.input().split()))
ans = 0
li.sort()
for i in range(3*N):
  if i%3 == 1:
    ans += li[i]
print(ans)

Submission status: Runtime Error

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *A =  map(int, read().split())

A = sorted(A)
A = A[N:-N]

print(sum(A))

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
x = len(a) // n
l = []
for i in range(n):
    for j in range(x):
        ll.append(a[i+j::x-1])
      
ans = 0
for i in range(n):
    ans += l[i][1]
print(ans)

Submission status: Runtime Error

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
from math import gcd

#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: Runtime Error

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

Submission status: Runtime Error

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


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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

for i in range(N):
  suma[3*N-2*(i+1)])
ans = sum(array)
print(ans)