jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n;
long long ans;
char s[200002];
map<int,int>v;
inline int ksm(re int x,re int y){
	re int an=1;
	while(y){
		if(y&1)an=an*x%2019;
		x=x*x%2019;
		y>>=1;
	}
	return an;
}
inline void work(re int l,re int r){
	if(l==r)return;
	re int mid=l+r>>1;
	v.clear();
	re int pw=1,m=0;
	for(re int i=mid;i>=l;--i){
		m=m+(s[i]-'0')*ksm(10,mid-i);
		m%=2019;
		++v[m];
	}
	m=0;
	for(re int i=mid+1;i<=r;++i){
		m=m*10+s[i]-'0';
		m%=2019;
		pw*=10;
		pw%=2019;
		for(re int j=0;j<=2018;++j)if((j*pw+m)%2019==0){
			ans+=v[j];
			break;
		}
	}
	work(l,mid),work(mid+1,r);
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	work(1,n);
	printf("%lld\n",ans);
}
//  [c]
#include<stdio.h>
int main (void)
{
    int i,a=0,k;
    int s;
    int b[2019]={0};
    int l[2019];
    while(1){
        s=getchar();
        if(s==10)break;
        k=s-'0';
        for(i=0;i<2019;i++)l[(i*10+k)%2019]=b[i];
        l[k]++;
        a+=l[0];
        for(i=0;i<2019;i++)b[i]=l[i];
    } 
    printf("%d",a);
}
//  [c]
#include <stdio.h>

int main()
{
	char S[200001];
	scanf("%s", S);
	
	int i, j, k, res[2][2019] = {};
	long long count = 0;
	for (i = 1, res[0][S[0]-'0'] = 1; S[i] != 0; i++) {
		for (j = 0; j < 2019; j++) {
			k = (j * 10 + S[i] - '0') % 2019;
			res[i%2][k] = res[1-i%2][j];
		}
		res[i%2][S[i]-'0']++;
		count += res[i%2][0];
	}
	
	printf("%lld\n", count);
	fflush(stdout);
	return 0;
}
//  [javascript]
console.log((args=>{
  const S = args.trim().split``.map(v=>v|0);
  const L = S.length;
  const M = Array(2019).fill(0);
  let e = 0, d = 1;
  for ( let i = L-1; i >=0; i-- ) {
    e = (e + S[i] * d)%2019;
    M[e]++;
    d = d*10%2019;
  }
  let a = M[0];
  for ( let i = 0; i < 2019; i++ ) {
    if ( M[i] < 2 ) continue;
    a += M[i] * (M[i]-1) / 2;
  }
  return `${a}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")
;(input => {
    const S = input.split("\n")[0]
    const mod = 2019
    const map = Array(2019).fill(0)
    map[0] = 1
    let c = 0
    let p = 1
    let m = 0

    for (let i = S.length - 1; i >= 0; i--) {
        m = (m + S[i] * p) % mod
        c += map[m]
        map[m]++
        p = p * 10 % mod
    }

    console.log(c)

})(input)
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = (arg[0].split(" ")[0]);
    const N = S.length;
    
    let answer = 0;
    let cnt = [...Array(2020)].fill(0);
    cnt[0] = 1;
    
    let total = 0;
    let p = 1;
    
    for(let i=N-1; i>=0; i--) {
        total = (total + parseInt(S[i]) * p) % 2019;
        
        // console.log("total:" + total);
        // console.log("S[i]:" + S[i]);
        
        answer += cnt[total];
        
        p = (p * 10) % 2019;
        // console.log("p:" + p);
        // console.log("------");
        cnt[total]++;
    }
    
    // console.log(cnt);
    console.log(answer);
    
    // console.log(7121 % 2019)
    // console.log(14 % 2019)
    // console.log(712114 % 2019)
    // console.log(712100 % 2019)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

func reverse(s string) (result string) {
	for _, v := range s {
		result = string(v) + result
	}
	return
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	N := 2019
	s := reverse(scanText())
	m := make([]int, N)
	total := 0
	d := 1
	m[0] = 1
	for _, c := range s {
		n, _ := strconv.Atoi(string(c))
		total += n * d
		total %= 2019
		d = (d * 10) % N
		m[total]++
	}
	sum := 0
	for _, v := range m {
		sum += v * (v - 1) / 2
	}
	fmt.Println(sum)
}
//  [go]
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	S := sc.nextStr()
	ans := 0
	var dp [2019]int
	for i := 1; i < len(S)+1; i++ {
		var ndp [2019]int
		d := int(S[i-1] - '0')
		for j := 0; j < 2019; j++ {
			ndp[(j*10+d)%2019] += dp[j]
		}
		ans += ndp[0]
		ndp[d] += 1
		dp = ndp
	}

	fmt.Fprintln(wtr, ans)
}
//  [ruby]
def pow10(d)
  if d.zero?
    1
  elsif d == 1
    10
  elsif d.odd?
    (10 * pow10(d - 1)) % 2019
  else
    (pow10(d / 2) ** 2) % 2019
  end
end

S = gets.chomp
ans = 0
dp = Array.new(2020, 0)
dp_mod = Array.new(S.size + 1, 0)
dp[0] = 1

(1 .. S.size).each do |d|
  s = S[-d].to_i
  dp_mod[d] = (s * pow10(d) + dp_mod[d - 1]) % 2019
  ans += dp[dp_mod[d]]
  dp[dp_mod[d]] += 1
end
puts ans
//  [ruby]
require "forwardable"

MOD = 2019
class Modint
  extend Forwardable
  def_delegators :@a, :hash, :to_i
  
  def initialize(a); @a = a.to_i % MOD; end
  def + (other); Modint[@a + other.to_i]; end
  def - (other); Modint[@a - other.to_i]; end
  def * (other); Modint[@a * other.to_i]; end
  def ** (other); Modint[@a.pow other.to_i, MOD]; end
  def / (other); Modint[@a * other.to_i.pow(MOD-2, MOD)]; end
  def eql? (other); @a.eql? other.to_i; end
  def inspect; "#{@a}"; end
  def coerce(other); [self, other]; end
  
  alias :pow :**
  class << self; alias :[] :new; end
end
M = Modint

a = gets.chomp.chars.map(&:to_i).reverse
n = a.size
dp = Array.new(n+1)
dp[0] = M[0]

n.times do |i|
  dp[i+1] = 10.pow(i,MOD) * a[i] + dp[i]
end
ans = dp.tally.values.map{ |v| v*(v-1)/2 }.sum
puts ans
//  [ruby]
require "forwardable"

MOD = 2019
class Modint
  extend Forwardable
  def_delegators :@a, :hash #, :to_i
  
  def initialize(a); @a = a.to_i % MOD; end
  def + (other); Modint[@a + other.to_i]; end
  def - (other); Modint[@a - other.to_i]; end
  def * (other); Modint[@a * other.to_i]; end
  def ** (other); Modint[@a.pow other.to_i, MOD]; end
  def / (other); Modint[@a * other.to_i.pow(MOD-2, MOD)]; end
  def eql? (other); @a.eql? other.to_i; end
  def to_i; @a.to_i; end
  def inspect; "#{@a}"; end
  def coerce(other); [self, other]; end
  
  alias :pow :**
  class << self; alias :[] :new; end
end
M = Modint

a = gets.chomp.chars.map(&:to_i).reverse
n = a.size
dp = Array.new(n+1)
dp[0] = M[0]

n.times do |i|
  dp[i+1] = 10.pow(i,MOD) * a[i] + dp[i]
end
ans = dp.tally.values.map{ |v| v*(v-1)/2 }.sum
puts ans
//  [rust]
#![allow(unused)]

use std::io::{Read, Stdin, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
	eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

struct TokenReader<'a> {
    lock: StdinLock<'a>,
}

impl<'a> TokenReader<'a> {
    fn new(s: &'a Stdin) -> TokenReader<'a> {
        TokenReader { lock: s.lock() }
    }

    fn read_chars<T: FromIterator<char>>(&mut self) -> T {
        self.lock
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<T>()
    }

    fn read_str(&mut self) -> String {
        self.read_chars::<String>()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_str().parse().ok().unwrap()
    }
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn main() {
    let sin = std::io::stdin();
    let mut tr = TokenReader::new(&sin);

    let s: Vec<usize> = tr.read_chars::<Vec<char>>()
        .into_iter()
        .map(|c| c.to_digit(10).unwrap() as usize)
        .collect();
    let n = s.len();

    let mut dp = vec![vec![0i16; 2019]; n];
    for i in 0..n {
        dp[i][s[i]] += 1;
        if i >= 1 {
            for r in 0usize..2019 {
                dp[i][(r * 10 + s[i]) % 2019] += dp[i - 1][r];
            }
        }
    }

    println!("{}", (0..n).fold(0i64, |a, i| a + dp[i][0] as i64));
}
//  [swift]
let s = readLine()!
let mod = 2019

func pow(_ a: Int, _ n: Int, _ mod: Int? = nil) -> Int {
  var a = a
  var n = n
  var result: Int = 1
  if let unwrappedMod = mod {
    while n > 0 {
      if n & 1 == 1 { result = result * a % unwrappedMod }
      n >>= 1
      a = a * a % unwrappedMod
    }
    return result
  } else {
    while n > 0 {
      if n & 1 == 1 { result *= a }
      n >>= 1
      a *= a
    }
    return result
  }
}

var tmp = 0
var remainders: [Int: Int] = [0: 1]
for (i, char) in s.reversed().enumerated() {
  let num = Int(String(char))!
  tmp += num * pow(10, i, mod)
  tmp %= mod
  if tmp < 0 { tmp += mod }
  if let v = remainders[tmp] {
    remainders[tmp] = v + 1
  } else {
    remainders[tmp] = 1
  }
}

var result = 0
for v in remainders.values {
  result += v * (v - 1) / 2
}

print(result)
//  [python]
import math
import numpy as np
a,b=[int(v) for v in input().split()]

min_8=math.ceil(a/0.08)
max_8=(a+1)//0.08

min_10=math.ceil(b/0.1)
max_10=(b+1)//0.1


range_8 = np.arange(min_8,max_8+1).astype(int)
range_10 = np.arange(min_10,max_10+1).astype(int)

try:
    print(min(np.intersect1d(range_8,range_10)))
except:
    print(-1)
//  [python]
def main():
    import numpy as numpy
    import sys
    A,B=list(map(int,sys.stdin.readline().split()))
    for price in range(10001):
        if int(price*0.08)==A and int(price*0.1)==B:
            return price
    
    return -1

print(main())
//  [python]
import numpy as np
A, B = map(int, input().split())

x_A_max = (A+1)/0.08
x_A_min = np.ceil(A/0.08)

x_B_max = (B+1)/0.1
x_B_min = np.ceil(B/0.1)

if (x_A_max<=x_B_min)or(x_A_min>=x_B_max):
    print(-1)
elif x_A_min<x_B_min:
    print(int(x_B_min))
else:
    print(int(x_A_min))
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[1000000000*2];
		int a = sc.nextInt();
		int b = sc.nextInt();
		//System.out.println((int)Math.floor(1.5));
		for (int i=1;100000000>i;i++) {
			double c = i*0.08;
			//System.out.println((int)c);
			if((int)Math.floor(c)== a) {
				double d = i*0.1;
				if((int)Math.floor(d)== b) {
					System.out.println(i);
					System.exit(0);
				}
			}
		}
		System.out.println("-1");
	}
}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        if(A > B) {
            System.out.println(-1);
            return;
        }

        for(int i = 1; i < 99999999; i ++) {
            if((int)(i * 0.08) == A &&  (int)(i * 0.10) == B) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}
//  [cpp]
#include<iostream>
#include<cmath>
#include<sstream>

using namespace std;


unsigned int A;
unsigned int ah;
unsigned int B;
unsigned int bh;
long int x;
unsigned int i;


int main() {

	cin >> A >> B;

	while (1) {
		i++;
		ah = i * 0.08;
		bh = i * 0.10;

		if (ah == A) {

			if (bh == B) {

				x = i;

				break;
			}

		}

		if (i > 1000000000) {
			x = -1;
			break;
		}

	}

	cout << x << endl;

	return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(double i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b;
  cin >> a >> b;
  REP(i, 1001001001){
    int A = i * 0.08;
    int B = i * 0.1;
    if(A == a && B == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
//  [cpp]
#include<iostream>
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  int ans;
  for(int i=1;i<1e9;i++){
    int a_ans=i*0.08;
    int b_ans=i*0.1;
    if(a_ans==a&&b_ans==b) {
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}
//  [c]
#include<stdio.h>
int main()
{
  int A,B;
  int x = 0;
  scanf("%d %d",&A,&B);
  while (x < 1000000000)
  {
  	if ((((float)x*0.08 >= A) && ((float)x*0.08 < A + 1)) && (((float)x*0.1 >= B) && ((float)x*0.1 < B + 1)))
  	{
    	printf("%d",x);
      	return (0);
  	}
    x++;
  }
  printf("%d",-1);
}
//  [c]
#include <stdio.h>

int main(){
  int ans=-1;
  int A,B;
  scanf("%d %d",&A,&B);
  for(int i=1;i<=20000;i++){
    if((i*8)/100==A && (i*10)/100==B){
      ans=i;
      break;
    }
  }
  printf("%d\n",ans);
  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>

int warizan(int a, float tax)
{
    return a*tax;
}

int main(void)
{
    int A, B, i, flag=0;
    scanf("%d%d", &A, &B);
    for(i=1; i<1009; i++){
        if(A==warizan(i,0.08) && B==warizan(i,0.10)){
            flag=1;break;
        }
    }
    if(flag==1){
        printf("%d", i);
    }else{
        printf("%d", -1);
    }

    return 0;
}
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(" ")
A = l.shift() * 1
B = l.shift() * 1
ans = -1
for (i=0; i<=10000; i++) {
    if (Math.floor(i*0.08) == A && Math.floor(i*0.1) == B) {
        ans = i;
        break;
    }
}
console.log(ans)
//  [javascript]
function Main(arg)
{
  var A = arg.split("\n")[0].split(" ")[0]-0;
  var B = arg.split("\n")[0].split(" ")[1]-0;

  for (var i = 1; i <= 1000; i++){
    var a = Math.floor(i*0.08);
    var b = Math.floor(i*0.1);
    if (A === a && B === b) {
      console.log(i);
      return;
    }
  }

console.log(-1);
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
	input = input.split(" ").map(Number);
	var n = -1;
	for(var i=input[0]*12;i<(input[0]*12)+1000;i++){
		if(Math.floor(i*0.08)==input[0]&&Math.floor(i*0.1)==input[1]){
			n = i;
			break;
		}
	}
	console.log(n)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

// 0.08かけして切り捨ててA円
// 0.1かけして切り捨ててB円
// 0.1でわると1桁目が切り捨てられる
// 0.08でわると整数部が税額
// 1. 1 から1250までループ
// 2. ループ値を0.08でわった整数部がaと一致するものを探す
// 3. その値を ループ値を0.1かけした整数部が一致すればその値を出力して終了

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	for i := 0; i < 1250; i++ {
		noTaxPrice := i + 1
		taxEight := float32(noTaxPrice) * 0.08
		if int(taxEight) == a {
			if int(float32(noTaxPrice)*0.1) == b {
				fmt.Println(noTaxPrice)
				return
			}
		}
	}
	fmt.Println(-1)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)

	for i := 1; i < 1005; i++ {
		if i*8/100 == a && i*10/100 == b {
			fmt.Fprintln(writer, i)
			return
		}
	}
	fmt.Fprintln(writer, -1)
}
//  [go]
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	min := Max((100*A+7)/8, (100*B+9)/10)
	max := Min((100*A+100+7)/8, (100*B+100+9)/10) - 1
	if min <= max {
		fmt.Println(min)
	} else {
		fmt.Println(-1)
	}
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
//  [ruby]
a,b = gets.split(' ').map(&:to_i)

result = -1
1.upto(10000000) do |i|
  next unless result == -1
  result = i if (i*0.08).floor == a && (i*0.1).floor == b
end

puts result
//  [ruby]
a,b = gets.chomp.split(' ').map(&:to_f)
i=1
while true
    if ((i*0.08).floor == a) && ((i*0.1).floor == b)
        puts i.to_i
        break
    elsif i > 1000000
        puts "-1"
        break
    end
    i+=1
end
//  [ruby]
def f(i, r)
   (i * r / 100 - i).to_i
end

a, b = gets.split.map(&:to_i)

ans = -1
for i in 0..1000000
    if f(i,108) == a && f(i,110) == b
        ans = i 
        break
    end
end

puts ans
//  [typescript]
import { createInterface } from 'readline';

const main = (lines: string[]) => {
  console.log(solve(lines));
};

export const solve = (lines: string[]): string => {
  const { A, B } = parseLines(lines);

  const N1: number[] = [];
  for (let i = 1; i < 1001; i++) {
    if (Math.floor(i * 0.08) === A) {
      N1.push(i);
    }
  }

  const N2: number[] = [];
  for (let i = 1; i < 1001; i++) {
    if (Math.floor(i * 0.1) === B) {
      N2.push(i);
    }
  }

  const N = N1.find(n1 => N2.findIndex(n2 => n1 === n2) !== -1);

  return (N || -1).toString();
};

const parseLines = (lines: string[]) => {
  const [A, B] = lines[0].split(' ').map(e => +e);
  const obj = { A, B };
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) {
    console.log(message, ...optionalParams);
  }
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines: string[] = [];
  createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}
//  [typescript]
import { createInterface } from 'readline';

// find使わない版

const main = (lines: string[]) => {
  console.log(solve(lines));
};

export const solve = (lines: string[]): string => {
  const { A, B } = parseLines(lines);

  const N1: number[] = [];
  for (let i = 1; i < 1001; i++) {
    if (Math.floor(i * 0.08) === A) {
      N1.push(i);
    }
  }

  const N2: number[] = [];
  for (let i = 1; i < 1001; i++) {
    if (Math.floor(i * 0.1) === B) {
      N2.push(i);
    }
  }

  for (let i = 0; i < N1.length; i++) {
    for (let j = 0; j < N2.length; j++) {
      if (N1[i] === N2[j]) {
        return N1[i].toString();
      }
    }
  }

  return '-1';
};

const parseLines = (lines: string[]) => {
  const [A, B] = lines[0].split(' ').map(e => +e);
  const obj = { A, B };
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) {
    console.log(message, ...optionalParams);
  }
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines: string[] = [];
  createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}
//  [typescript]
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let a: number = 0;
    let b: number = 0;
    let ans: number = 0;
    // init
    [a, b] = input.shift().split(" ").map(x => Number(x));
    // solve
    ans = -1;
    for (var rx = 0; rx <= 1010; rx++) {
        if (Math.floor(rx * 0.08) == a &&
            Math.floor(rx * 0.10) == b) {
            ans = rx;
            break;
        }
    }
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();
//  [python]
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())
A.sort()
x = sum(A[N::2])
print(x)
//  [python]
#!/usr/bin/env python3


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


main()
//  [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())
//  [python]
#!/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])
//  [python]
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    a.sort(key = lambda x:-x)
    ans = 0
    for i in range(n):
        ans += a[2*i+1]
    print(ans)
    return

#B
def B():
    def dfs(d,x,c):
        if d <= dp[x]:
            return
        dp[x] = d
        if not f[x]:
            f[x] = c
        for y in v[x]:
            dfs(d-1,y,c)
    n,m = LI()
    f = [0]*n
    v = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    dp = defaultdict(lambda : -1)
    q = I()
    l = LIR(q)
    l = l[::-1]
    for x,d,c in l:
        x -= 1
        dfs(d,x,c)
    for i in f:
        print(i)
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()
//  [java]
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		long[] a = new long[3*N];
		for(int i = 0; i < 3*N; i++) a[i] = sc.nextLong();
		Arrays.sort(a);
		long ans = 0;
		for(int i = N; i < 3*N; i += 2) ans += a[i];
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}
//  [java]
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Long a[] = new Long[3 * n];
        for (int i = 0; i < 3 * n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a, Collections.reverseOrder());

        long sum = 0;
        int count = 0;
        for (int i = 1; i < 3 * n; i += 2) {
            if (count == n) {
                break;
            }
            sum += a[i];
            count++;
        }
        System.out.println(sum);
    }
}
//  [java]
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		int n = s.nextInt();
		BigInteger array[] = new BigInteger[n * 3];
		for (int i = 0; i < array.length; i++) {
			array[i] = BigInteger.valueOf(s.nextInt());
		}
		s.close();
		System.out.println(Main.calc(n, array));
	}

	private static BigInteger calc(int n, BigInteger[] array) {
		BigInteger res = BigInteger.ZERO;
		java.util.Arrays.sort(array, java.util.Collections.reverseOrder());
		for (int i = 0; i < n; i++) {
			res = res.add(array[1+i * 2]);
		}
		return res;
	}
}
//  [java]
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO Auto-generated constructor stub
	}

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int N = sc.nextInt();
		Long[] a = new Long[3*N];
		for(int i = 0; i < 3*N; i++)
			a[i] = sc.nextLong();
		sc.close();
		List<Long> aList = Arrays.asList(a);
		Collections.sort(aList);
		BigInteger sum = BigInteger.ZERO;
		for(int i = aList.size() - 2; i >= N; i -= 2) {
			sum = sum.add(BigInteger.valueOf(aList.get(i)));
		}	
		System.out.println(sum);
	}

}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 12 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[300001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int A[300000];
	rep(i, 3 * N) A[i] = getint();
	pakuri_sort(3 * N, A);

	ll kotae = 0;
	for (int i = N; i < 3 * N; i += 2) kotae += A[i];

	printf("%lld\n", kotae);

	Would you please return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N = getint();
	int A[300000];
	rep(i, 3 * N) A[i] = getint();
	sort(A, A + 3 * N);

	ll kotae = 0;
	for (int i = 3 * N - 2; i > N - 1; i -= 2) {
		kotae += A[i];
	}
	co(kotae);

	Would you please return 0;
}
//  [cpp]
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

int main() {
  ll n;
  cin>>n;
  
  vector<ll> A(3*n);
  rep(i,3*n) cin>>A[i];

  sort(ALL(A),greater<int>());
  
  ll sum=0;
  for(int i=1;i<=n;i++){
    sum+=A[2*i-1];
  }
  
  cout<< sum <<endl;
  
  return 0;
}
//  [cpp]
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<char> A){rep(i,A.size()){cout << A[i];}cout << endl;}

int main(){
    int n;
    cin >> n;
    vector<int> a(3*n);
    rep(i,3*n) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    ll ans = 0;
    rep(i,2*n){
        if (i%2 != 0){ans += a[i];}
    }
    cout << ans;
}
//  [cpp]
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  int n;
  cin >> n;
  vector<ll> a(3*n);
  rep(i, 3*n) cin >> a[i];
  sort(all(a));
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[n + 2*i];
  }
  cout << ans << endl;
}
//  [c]
#include<stdio.h>
void swap (long long int *x,long long int *y) {
  long long int temp = *x;
  *x = *y;
  *y = temp;
}
int partition (long long int array[],long long int left,long long int right) {
  long long int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;
  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);
  swap(&array[pivot], &array[j]);
  return j;
}
void quick_sort (long long int array[],long long int left,long long int right) {
  long long int pivot;
  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);
    quick_sort(array, pivot+1, right);
  }
}

int main(){
  long long int n,ans = 0,i;
  scanf("%lld",&n);
  long long int a[3 * n];
  for(i = 0;i < 3 * n;i++){
    scanf("%lld",&a[i]);
  }
  quick_sort(a,0,3 * n - 1);
  for(i = n;i < 3 * n;i += 2){
    ans += a[i];
  }
  printf("%lld\n",ans);
  return 0;
}
//  [c]
#include <stdio.h>
#define swap(type, x, y)  do{ type t = x; x = y; y = t; }while(0)

void quick(long array[], int left, int right){
  int pl = left, pr = right;
  long x = array[(pl + pr) / 2];
  do{
    while(array[pl] > x)  pl++;
    while(array[pr] < x)  pr--;
    if(pl <= pr){
      swap(long, array[pl], array[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(array, pl, right);
  if(pr > left)  quick(array, left, pr);
}

int main(){
  int n;  scanf("%d", &n);
  long a[300005];
  for(int i=1; i<=n*3; i++)
    scanf("%ld", a+i);
  quick(a, 1, n*3);
  long ans = 0;
  for(int i=n+1; i<=n*2; i++)
    ans += a[i];

  long anss = 0;
  for(int i=1; i<=n; i++)
    anss += a[i*2];

  // anss = anss>ans ? anss : ans;
  printf("%ld\n", anss);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

typedef long long int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right)
/* クイックソート
 * a     : ソートする配列
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            i++; j--;
        }
        quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}


int main(void){


	int n;
	scanf("%d",&n);
	long long int *a;
	a=(long long int*)malloc(3*n*sizeof(long long int));

	int i;
	for(i=0;i<3*n;i++){
		scanf("%lld",a+i);
	}

	quicksort(a,0,3*n-1);

	long long int sum=0;
	for(i=3*n-2;i>=n;i-=2){
		sum+=a[i];
	}
	free(a);
	printf("%lld\n",sum);
	return 0;
}
//  [c]
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,a,i,d[300010];
  long long s=0;
  scanf("%d",&n);
  for(i=0;i<3*n;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=0;i<3*n;i++)d[i]=N[hout()];
  for(i=0;i<n;i++)s=s+d[i*2+n];
  printf("%lld\n",s);
  return 0;
}
//  [c]
// https://atcoder.jp/contests/agc012/tasks/agc012_a
// A - AtCoder Group Contest
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}


// intバブルソート
void sort(int a[], int num) {
    int i, j, b;
    for (i = 0; i < num-1; i++) {
        for (j = 0; j < num-i-1; j++) {
            if (a[j] > a[j+1]) {
                b = a[j];
                a[j] = a[j+1];
                a[j+1] = b;
            }
        }
    }
}

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void) {
    int a[300000];
    int n;
    long sum = 0;
    n = get_num();
    //n = 100000;

    for (int i = 0; i < 3 * n; i++) {
        //a[i] = 1000000000;
        a[i] = get_num();
    }

//    sort_q(a, n*3);
    qsort(a, n*3, sizeof(int), compare_int);
    
    for (int i = 0; i < n; i++) {
        sum += a[n*3-1 - (i*2+1)];
    }
    
    printf("%ld", sum);
    
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
int num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
int asc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
int main(void){
    int n, i, j=1;
    int a[300001];
    long ans=0;
    
    n = num();
    for(i=0; i<n*3; i++){
        a[i] = num();
    }
    
    qsort(a, n*3, sizeof(int), asc);
    
    for(i=0; i<n; i++){
        ans += a[j];
        j+=2;
    }
    
    printf("%ld\n", ans);
    
    return 0;
}
//  [javascript]
// https://atcoder.jp/contests/agc012/tasks/agc012_a
"use strict";
function Main(input) {
  const params = input.trim().split("\n");
  const N = Number(params[0].trim());
  const sortedA = params[1]
    .trim()
    .split(" ")
    .map(Number)
    .sort((a, b) => b - a);

  let total = 0;
  for (let i = 0; i < N; i++) {
    total += sortedA[i * 2 + 1];
  }

  console.log(total);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const N = lines[0]-0;
    const list = lines[1].split(" ").map(v=>v-0).sort((a,b)=>b-a);
    let ans = 0;
    for(let i=1;i<N*2;i+=2){
        ans += list[i];
    }
    console.log(ans);
});
//  [javascript]
function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  let ary = args[1].split(' ').map(n => parseInt(n, 10));
  let count = 0;
  let ans = 0;
  
  ary = ary.sort((a, b) => a - b);
  
  if (N === 1) {
  	ans = ary[1];
  } else {
    while(true) {
      ans += ary[N + (2 * count)];
      count++;
      if (count === N) { break; }
    }
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
	var len = parseInt(input.split("\n")[0]);
  var list = input.split("\n")[1].split(" ");
   var output = 0;
  list.sort(function(a,b){
  	return parseInt(b) - parseInt(a);
  });
  
  var count = 0;
  while(count < len){
    output += parseInt(list[(count * 2) + 1]);
    count++
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next(); //("00000" + nexts()).substr(-5).split("").map(x => +x);
    let a = nexts(3 * n).sort((a, b) => b - a);
    let ans = 0;
    for (let i = 0; i < n; i++) {
        ans += a[2 * i + 1]
    }

    return ans;
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := getInts(N * 3)
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})
	ans := 0
	// out(a)
	for i := 0; i < N; i++ {
		ans += a[1+i*2]
	}

	out(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	a := make([]int, 3*N)
	for i := 0; i < 3*N; i++ {
		a[i] = nextInt()
	}
	sort.Ints(a)

	ans := 0
	for i := 0; i < N; i++ {
		ans += a[3*N-2-2*i]
	}

	fmt.Println(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	al := make([]int, 3*n)

	for i := 0; i < 3*n; i++ {
		al[i] = nextInt()
	}
	sort.Ints(al)

	ssum := 0
	for i := 0; i < n; i++ {
		ssum += al[3*n-2-i*2]
	}

	fmt.Println(ssum)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}