Fix Wiring

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

You are in the spaceship The Skeld with your fellow crewmates. However, while checking the central power system, 
you found out that one crucial wiring installation of the central power system has been sabotaged. To prevent an engine failure, you should quickly fix the installation.

The installation consists of NN nodes and M=N(N1)2M=\frac{N(N-1)}{2} wires. All possible pairs of distinct nodes in the installation are connected with a wire. Originally, each of the MM wires had exactly one tag attached to it. Each tag has a positive integer value, and different tags may have the same value. However, due to the sabotage, all the tags were removed from the wires and left on the floor. Fortunately, you gathered all MM tags from the ground. Now, in order to fix the installation, you have to trigger the reboot sequence by re-attaching all the tags back to the wires twice.

For an installation where all wires have a tag on them, let's define the cost of an installation as the cost of its minimum spanning tree, that is, the minimum cost of a subset of wires such that all nodes are connected using only the given subset of wires. Here, the cost of the set of wires is defined as the sum of the tag values of all wires in the set.

The reboot sequence is triggered in two steps:
First, you should attach the tags to minimize the cost of the installation.
Then, after detaching all tags, you should attach the tags to maximize the cost of the installation.

Please compute the cost of each installation.

입력

The first line of the input contains an integer NN, representing the number of nodes. (2N1002 \le N \le 100)

The second line of the input contains M=N(N1)2M=\frac{N(N-1)}{2} positive integers C_1,C_2,C_MC\_1, C\_2, \cdots C\_M, representing the integer values of MM tags. (1C_i21091 \le C\_i \le 2 \cdot 10^9)

출력

Output a single line containing two integers. The first should be the minimum possible cost of the installation, the second should be the maximum possible cost of the installation.