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


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()

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

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

Solution (Python):

 
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)

Solution (Python):



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()

Solution (Python):

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)

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

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

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

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

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 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)

Solution (Python):



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)

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

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

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

n = int(input_lines)
aAry = input_lines2.split(' ')
aAry = map(int,aAry)
aAry = sorted(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)

Solution (Python):

"""
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)

Solution (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

Solution (Python):


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

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

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
n = map(int, raw_input().split())
x = map(int, raw_input().split())
x.sort(reverse = True)

sum = 0
if n[0]%2==0:
    for i in range(0, n[0]):
        sum = sum +x[i*2+1]
        
elif n[0]%2!=0:
    for i in range(0, (n[0]-1+1)):
        sum = sum +x[i*2+1]
print sum

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

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)

Solution (Python):
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

Solution (Python):
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)

Solution (Python):
N = int(input())
a = [int(i) for i in 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()
res = sum(a[n::2])
print(res)

Solution (Python):
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)

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

Solution (Python):

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)

Solution (Python):
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)

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

a.reverse()

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

Solution (Python):
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)]))

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

Solution (Python):
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)

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

a.sort()
a.reverse()

b = a[1::2]

result = sum(b[:N])

print(result)

Solution (Python):
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)

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

Solution (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])

Solution (Python):
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)

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

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

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

Solution (Python):
"""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()

Solution (Python):
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

Solution (Python):
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()

Solution (Python):
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(max(answer,temp))

Solution (Python):
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

Solution (Python):



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)

Solution (Python):
import sys

cin = sys.stdin


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


print(ans)

Solution (Python):

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])

Solution (Python):
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)

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

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

Solution (Python):


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)

Solution (Python):
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])

Solution (Python):

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

Solution (Python):
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()

Solution (Python):
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())

Solution (Python):
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

Solution (Python):
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)

Solution (Python):
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


n = int(input())
people = sorted(list(map(lambda x: int(x), input().split())), reverse=True)
print(strength(n, people))

Solution (Python):

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)

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

a.sort()



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

print(ans)

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

Solution (Python):
N = int(input())
a = [int(i) for i in 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()
a.reverse()
total = 0
for i in range(N):
    total += a[i*2 + 1]
print(total)