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: Wrong Answer

Solution code:
N = int(raw_input())
list = map(int, raw_input().split(" "))
list.sort(reverse=True)
total = long(0)
unit = len(list) / 3
for i in range(unit, unit * 2):
    total += long(list[i])
print total

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
list = map(int, raw_input().split(" "))
list.sort(reverse=True)
total = 0
unit = len(list) / 3
for i in range(unit, unit * 2):
    total += list[i]
print total

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
ans1=sum(b[N:2*N])

ans2=0
for i in range(N):
    ans2 += b[i*3+1]

print(max(ans1,ans2))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
ans1=sum(b[N:2*N])

print(ans1)

Submission status: Wrong Answer

Solution code:
#AGC012A

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

Submission status: Wrong Answer

Solution code:

def f(n):
    if n == 1:
        return []
    if n % 2 == 0:
        r = f(n//2)
        k = len(r)
        return r + [k+1]
    if n % 2 == 1:
        r = f(n - 1)
        k = len(r)
        return [k+1] + r

n = int(input())
r = f(n+1)
k = len(r)
res = r + list(range(1, k+1))
print(len(res))
for x in res:
    print(x, end=' ')
print()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x.sort()
print(sum(x[n:n*2]))

Submission status: Wrong Answer

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)
    
prob_a(n=n, a=a)

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N-1, -1, -1):
    for j in range(i-1, -1, -1):
        if x[i][1] == x[j][1] and x[j][2] < x[i][1] and x[i][2] > x[j][2]:
            x[j][2], x[i][1] = x[i][1], x[j][2]
            break
        else:
            break


res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

Solution code:
import itertools

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

    for x in itertools.permutations(a, 3*N):
        t = [x[i:i+3] for i in range(0, N*3, 3)]

        j = 0
        p = 0
        pwr = []
        while j < len(t):
            p += sorted(t[j])[1]
            j += 1
        pwr.append(p)
    print(max(pwr))

main()

Submission status: Wrong Answer

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

print(answer1)

Submission status: Wrong Answer

Solution code:
import itertools

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


    for x in itertools.permutations(a, 3*N):
        t = [x[i:i+3] for i in range(0, N*3, 3)]

        j = 0
        p = 0
        pwr = []
        while j < len(t):
            p += sorted(t[j])[1]
            pwr.append(p)
            j += 1
    print(max(pwr))

main()

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N-1, -1, -1):
    for j in range(i-1, -1, -1):
        if x[i][1] == x[j][1]:
            if x[j][2] < x[i][1]:
                x[j][2], x[i][1] = x[i][1], x[j][2]
                break
        else:
            break


res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N-1, -1, -1):
    for j in range(i-1, -1, -1):
        if x[i][1] == x[j][1]:
            if x[j][2] < x[i][2]:
                x[j][2], x[i][1] = x[i][1], x[j][2]
                break
        else:
            break


res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(float, input().split()))
a.sort()
S = 0.0
for i in a[N:2*N]:
	S += i

print(int(S))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(float, input().split()))
a.sort()
S = 0.0
for i in a[N:2*N]:
	S += i

print(S)

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N-1, -1, -1):
    for j in range(i-1, -1, -1):
        if x[i][1] == x[j][1]:
            if x[j][2] < x[i][2]:
                x[j][2], x[i][1] = x[i][1], x[j][2]
                break

res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

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

print(S)

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N-1, -1, -1):
    for j in range(i-1, -1, -1):
        if x[i][1] == x[j][1]:
            if x[j][2] < x[i][2]:
                tmp = x[j][2]
                x[j][2] = x[i][1]
                x[i][1] = tmp
                break

res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = input()
a = list(map(int, n.split()))
a.sort()
a1 = a[0:N]
a2 = a[N:2*N]
a3 = a[2*N:3*N]

sum1 = sum(a2)

a[2*N-1], a[2*N] = a[2*N], a[2*N-1]
a2 = a[N:2*N]

sum2 = sum(a2)
if sum1 >= sum2:
	print(sum1)
else:
	a[2*N-2], a[2*N+1] = a[2*N+1], a[2*N-2]
	a2 = a[N:2*N]
	sum3 = sum(a2)
	if sum2 >= sum3:
		print(sum2)
	else:
		print(sum3)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = input()
a = list(map(int, n.split()))
a.sort()
a1 = a[0:N]
a2 = a[N:2*N]
a3 = a[2*N:3*N]

sum1 = sum(a2)

a[2*N-1], a[2*N] = a[2*N], a[2*N-1]
a2 = a[N:2*N]

sum2 = sum(a2)
if sum1 >= sum2:
	print(sum1)
else:
	print(sum2)

Submission status: Wrong Answer

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

N = int(input())
a = input().split()

total = 0
a2 = sorted(a, reverse=True)
i = N + 1
j = 2 * N

for id in range(i, j+1):
	total += int(a2[id])

print(total)

Submission status: Wrong Answer

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

a.sort(reverse=True)


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

print output

Submission status: Wrong Answer

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

a.sort(reverse=True)

print a

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

print output

Submission status: Wrong Answer

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

N = int(input())
a = input().split()

total = 0
a2 = sorted(a)
i = N + 1
j = 2 * N

for id in range(i, j+1):
	total += int(a2[id])

print(total)

Submission status: Wrong Answer

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

N = int(input())
a = input().split()

total = 0
a2 = sorted(a)
i = N + 1
j = 2 * N

for id in range(i, j+1):
	print(id)
	total += int(a2[id])

print(total)

Submission status: Wrong Answer

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

l.sort()
l.reverse()

s = 0

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

print(s)

Submission status: Wrong Answer

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+1]
        #print i
elif n[0]%2!=0:
    for i in range(0, (n[0]-1+1)):
        sum = sum +x[i+1]
print sum

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N-1, -1, -1):
    for j in range(i-1, -1, -1):
        if x[i][1] == x[j][1]:
            if x[j][2] < x[i][2]:
                tmp = x[j][2]
                x[j][2] = x[i][1]
                x[i][1] = tmp

res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

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

a.sort()

for i in a[N+1:2*N+1]:
    output = output + long(i)

print output

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N-1, -1, -1):
    for j in range(i-1, -1, -1):
        if x[i][1] == x[j][1]:
            if x[j][2] < x[i][2]:
                tmp = x[i][2]
                x[i][2] = x[j][1]
                x[j][1] = tmp

res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

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

a.sort()

for i in a[N:2*N]:
    output = output + long(i)

print output

Submission status: Wrong Answer

Solution code:
N = int(input()) * 3
nexus = input().split()
nexus.sort()
i = 0
top = 0
while(i < N):
    nexus.pop()
    top += int(nexus.pop())
    nexus.pop(0)
    i +=3
print(top)

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

for i in range(N):
    for j in range(N-1, i, -1):
        if x[i][1] == x[j][1]:
            if x[j][2] > x[i][2]:
                tmp = x[i][2]
                x[i][2] = x[j][1]
                x[j][1] = tmp

res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

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

n=int(raw_input().strip())
a=map(int,raw_input().split())
a.sort()
a.reverse()
print sum(a[n:n*2])

Submission status: Wrong Answer

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)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input()) * 3
a = input().split()
nexus = sorted(a)
i = 0
top = 0
while(i < N):
    nexus.pop()
    top += int(nexus.pop())
    nexus.pop(0)
    i +=3
print(top)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ts = input().split(' ')
T = []
for i in range(0, N * 3):
    T.append(int(ts[i]))
    
T = sorted(T)
    
sum = 0
for i in range(N, N * 2):
    sum += T[i]
    
print(str(sum))

Submission status: Wrong Answer

Solution code:
import itertools,copy
n=int(input());a=list(map(int,input().split()))
l=list(itertools.permutations(a,3))
maximum=0
for li in l:
    b=copy.deepcopy(a)
    for i in li:b.remove(i)
    if maximum<sorted(li)[1]+sorted(b)[1]:maximum=sorted(li)[1]+sorted(b)[1] 
print(maximum)

Submission status: Wrong Answer

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

a.sort()

a=a[N:]

print sum(a[0:N])

Submission status: Wrong Answer

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

a.sort()

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

print output

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x = []
for n in range(N):
    x.append([])
    for i in range(3):
        x[n].append(0)

for i in range(N*3):
    x[i % N][i // N] = a[i]

res = 0

for n in range(N):
    res += x[n][1]

print(res)

Submission status: Wrong Answer

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

people.sort()

for i in range(N):
	people.pop()

accum = 0
for i in range(N):
	accum = accum + people.pop()

print(accum)

Submission status: Wrong Answer

Solution code:
s = int(raw_input())
a = raw_input()
aarray = a.split(" ")

aarray = sorted(aarray, reverse=True)

b = aarray[s : s * 2]
b = map(int, b)
print sum(b)

Submission status: Wrong Answer

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(n, 2 * n))
    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: Wrong Answer

Solution code:
import numpy as np


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

x = np.zeros((N, 3))

for i in range(N*3):
    x[i % N , i // N] = a[i]

res = 0

print(x)

for n in range(N):
    res += x[n, 1]

print(int(res))

Submission status: Wrong Answer

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(2, -1).sum(axis=0)[0])

Submission status: Wrong Answer

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

n = int(input_lines)
aAry = input_lines2.split(' ')
aAry = sorted(aAry)

answer = 0
for i in range(n):
    answer += int(aAry[(-i-1)*2])

print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
ts = input().split(' ')
T = []
for i in range(0, N * 3):
    T.append(int(ts[i]))
    
T = sorted(T)
    
sum = 0
for i in range(N, N * 2):
    sum += T[i]
    
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

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

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

Submission status: Wrong Answer

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

a.sort()

result = sum(a[N + 1: N * 2 + 1])

print(result)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
N = int(input())

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

inp.sort()
inp.reverse()

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(raw_input())

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

ans = 0

k = 0
i = 0

while k<n:
    temp = a[i: i+3]
    temp.sort()
    ans += temp[1]
    i += 3
    k += 1
    
print ans

Submission status: Wrong Answer

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

print sum(A[N:2*N])

Submission status: Wrong Answer

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]
print count

Submission status: Time Limit Exceeded

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

def solve(n, a):
    a.sort(reverse=True)
    cnt = 0
    for _ in [0]*n:
        cnt += a[1]
        del a[0:2]
        del a[-1]
    return cnt
    
print(solve(N, A))

Submission status: Time Limit Exceeded

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

A.sort(reverse=True)
cnt = 0
for _ in range(N):
    cnt += A[1]
    del A[0:2]
    del A[-1]
    
print(cnt)

Submission status: Time Limit Exceeded

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

A.sort(reverse=True)
cnt = []
for _ in range(N):
    cnt.append(A[1])
    del A[0:2]
    del A[-1]
    
print(sum(cnt))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

Solution code:
# AGC 012 A - AtCoder Group Contest
N = int(input())
an = list(map(int,input().split()))

lists = [[] for _ in range(N)]
for k in range(N):
    lists[k].append(max(an))
    del an[an.index(max(an))]
    lists[k].append(max(an))
    del an[an.index(max(an))]

for k in range(N):
    lists[k].append(max(an))
    del an[an.index(max(an))]
    
sasa = 0
for j in range(N):
    sasa += lists[j][1]
print(sasa)

Submission status: Time Limit Exceeded

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

# 1 2 4 5 5 5 7 8 9 
# 1 2 5 5 5 8

sum = 0
for i in range(N):
  #print(participants)
  c_max = participants.pop(0)
  n_max = participants.pop(0)
  c_min = participants.pop(-1)
  sum += n_max

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
member = sorted(map(int, input().split()))
ans = 0
while member:
    member.pop()
    ans += member.pop()
    member.pop(0)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

s = 0
while a:
    x = [a[0]] + a[-2:]
    s += x[1]
    a = a[1:-2]
print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
while len(A) > 0:
  ans += A[1]
  A = A[2:-1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

    res = 0
    for i in range(n):
        A.pop(0)
        A.pop(-1)
        res += A[-1]
        A.pop(-1)

    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()
# print(a)
ans = 0
for i in range(n):
    a = a[1:]
    a = a[:-1]
    ans += a[-1]
    a = a[:-1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()
# print(a)
ans = 0
for i in range(n):
    a.pop(0)
    a.pop(-1)
    ans += a[-1]
    a.pop(-1)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
data = list(map(int,input().split()))
data = sorted(data, reverse=True)
sum = 0
while data != []:
    del data[0]
    del data[-1]
    sum += data[0]
    del data[0]
print(sum)

Submission status: Time Limit Exceeded

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

ans=0
for i in range(n):
	del x[0]
	ans=ans+x[0]
	del x[0]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = input()
elem = list(map(int, input().split()))
elem.sort()
ans = 0
while len(elem) > 0:
    elem.pop(0)
    ans = ans + elem.pop(-2)
    elem.pop(-1)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a = sorted(list(map(int,input().split())),reverse=True)
ans=0
for i in range(2*N):
  tmp=a.pop(0)
  if i%2==1:
    ans+=tmp
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a = list(map(int,input().split()))
ans=0
for i in range(2*N):
  tmp=max(a)
  a.remove(tmp)
  if i%2==1:
    ans+=tmp
print(ans)

Submission status: Time Limit Exceeded

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

A.sort(reverse = True)
ans = []
while(len(A)>0):
    ans.append(A[1])
    A = A[2:len(A)-1]
print(sum(ans))

Submission status: Time Limit Exceeded

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

newLi = sorted(t, reverse=True)
li = []
ans = 0

for i in range(N):
  k = [newLi.pop(0), newLi.pop(0), newLi.pop(-1)]
  ans += k[1]

print(ans)

Submission status: Time Limit Exceeded

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

newLi = sorted(t, reverse=True)
li = []

for i in range(N):
  k = [newLi.pop(0), newLi.pop(0), newLi.pop(-1)]
  li.append(k)

ans = 0

for s in li:
  ans += s[1]

print(ans)

Submission status: Time Limit Exceeded

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

newLi = sorted(t, reverse=True)
li = []

for i in range(N):
  k = []

  k.append(newLi.pop(0))
  k.append(newLi.pop(0))
  k.append(newLi.pop(-1))

  li.append(k)

ans = 0

for s in li:
  ans += s[1]

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=sorted(map(int,input().split()),reverse=True)
b=[]
while len(a):
    for i in range(n):
        a.remove(max(a))
        b.append(max(a))
        a.remove(max(a))
        a.remove(min(a))
print(sum(b))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(sorted(list(map(int, input().split()))))
# N = 2
# A = list(sorted([5,2,8,5,1,5]))
group = []
ret = 0
for n in range(N):
    group.append([A.pop(0), A.pop(), A.pop()])
for g in group:
    ret += list(sorted(g))[1]
print(ret)