#C3821. Maximize Product of Remaining Array Elements
Maximize Product of Remaining Array Elements
Maximize Product of Remaining Array Elements
You are given an integer N
and an array of N
positive integers. You are allowed to perform an operation any number of times where you can combine elements in the array. After performing the operations, the task is to compute the maximum possible product of the remaining elements in the array.
It can be proven that, regardless of the sequence of operations, the maximum possible product is equal to the sum of all elements in the array. In other words, if the array elements are \(a_1, a_2, \dots, a_N\), then the answer is:
[ \text{Answer} = \sum_{i=1}^{N} a_i ]
Note: Even though the problem statement mentions an operation, the optimal strategy is to not perform any operation and simply compute the sum of all the array elements.
inputFormat
The first line contains a single integer N
representing the number of elements in the array. The second line contains N
space-separated integers representing the array elements.
For example:
3 1 2 3
outputFormat
Output a single integer, which is the maximum possible product of the remaining elements in the array (i.e. the sum of the array elements).
## sample1
100
100