#C2197. Maximum Value of the First Domino

    ID: 45486 Type: Default 1000ms 256MiB

Maximum Value of the First Domino

Maximum Value of the First Domino

You are given n domino pieces, each with an integer value. Initially, the value of the first domino is defined by the first element of the array. You are allowed to perform an operation any number of times: you can combine domino pieces by summing their values. The goal is to maximize the value of the first domino after performing these operations. It turns out that the optimal strategy is to add together all the values, thus the answer is given by $$S = \sum_{i=1}^{n} a_i.$$

inputFormat

The first line contains an integer n, representing the number of domino pieces. The second line contains n space-separated integers, where the i-th integer represents the value of the i-th domino.

outputFormat

Output a single integer denoting the maximum value that can be obtained for the first domino.## sample

3
1 2 3
6

</p>