#C8304. Maximize Tree Magic

    ID: 52272 Type: Default 1000ms 256MiB

Maximize Tree Magic

Maximize Tree Magic

In a mystical forest, there are (n) trees, each endowed with an initial magic level (a_i). By wisely casting spells, you can combine the magics from different trees to maximize the magic level of a single tree. The maximum magic level achievable is the sum of all trees' magic levels, i.e. (\sum_{i=1}^{n}a_i). However, to achieve this, a number of spells must be performed; precisely, the minimum number of spells required is (\sum_{i=1}^{n}a_i - \max_{1 \leq i \leq n}a_i). Given (n) and the list of magic levels, you are required to compute these two values.

inputFormat

The first line contains an integer (n) ((1 \le n \le 10^5)) representing the number of trees. The second line contains (n) space-separated integers (a_1, a_2, \dots, a_n) indicating the initial magic levels of the trees.

outputFormat

Output two space-separated integers: the maximum magic level that any tree can achieve and the minimum number of spells needed to reach that level.## sample

5
1 2 3 4 5
15 10