1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
        unsigned long long n;
        scanf("%llu", &n);
        std::vector<unsigned long long> c;
        unsigned long long nn = (n * (n + 1)) / 2;
        c.reserve(nn);
        for (unsigned long long i = 0ULL; i < nn; i++) {
                unsigned long long k;
                scanf("%llu", &k);
                c.push_back(k);
        }

        std::sort(c.begin(), c.end());
        unsigned long long s = 0ULL;
        for (unsigned long long i = 0ULL; i < n; i++)
                s += c[i];

        printf("%llu\n", s);
        return 0;
}