1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


#ifdef _WIN32

int inp()
{
	int n = 0;
	int ch = _fgetc_nolock(stdin);
	if (ch <= ' ') ch = _fgetc_nolock(stdin);
	while (ch > ' ') {
		n = 10 * n + ch - 48;
		ch = _fgetc_nolock(stdin);
	}
	return n;
}

#elif __linux

int inp()
{
	int n = 0;
	int ch = getchar_unlocked();
	if (ch <= ' ') ch = getchar_unlocked();
	while (ch > ' ') {
		n = 10 * n + ch - 48;
		ch = getchar_unlocked();
	}
	return n;
}

#endif


vector<int> heap;
long long int sum;

int main() {

	long long int n;
	cin >> n;

	int i;
	int c;

	for (i = 0; i < n*(n+1)/2; i++) {
		c = inp();
		heap.push_back(c);
	}

	make_heap(heap.begin(), heap.end());
	sort_heap(heap.begin(), heap.end());

	i = 0;

	for (int k : heap) {
		if (i++ == n) {
			break;
		}
		sum += k;
	}
	
	cout << sum;

	return 0;
}