import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] a) {
    a.sort();
    auto n = a.length / 3;
    long ans = 0;
    long p = a.length - 2;
    for (int i = 0; i < n; i++) {
        ans += a[p];
        p -= 2;
    }
    return ans;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}
