#K58952. Maximum Remaining Element

    ID: 30756 Type: Default 1000ms 256MiB

Maximum Remaining Element

Maximum Remaining Element

You are given an integer N and an array A containing N integers. You may perform the following operation repeatedly:

  • Select any two numbers from the array.
  • Replace one of them with the sum of the two while removing the other number.

This operation is performed exactly N-1 times until only one number remains. Your task is to compute the maximum possible value of the remaining element. It turns out that the final number is simply the sum of all the numbers in the array.

Note: All operations lead to the same final result.

inputFormat

The input is given in two lines:

  1. The first line contains a single integer N (1 ≤ N ≤ 105), representing the number of elements in the array.
  2. The second line contains N space-separated integers A1, A2, ..., AN (0 ≤ Ai ≤ 109), which are the elements of the array.

outputFormat

Output a single integer — the maximum possible value of the remaining element after performing the operations, which is the sum of all elements.

## sample
3
1 2 3
6

</p>