#K9496. Smallest, Largest, and Sum/Product Calculation

    ID: 38757 Type: Default 1000ms 256MiB

Smallest, Largest, and Sum/Product Calculation

Smallest, Largest, and Sum/Product Calculation

Given an array of integers, determine the smallest element, the largest element, and a resultant value computed as follows:

  • If the array is strictly sorted in ascending order, the resultant value is the sum of all its elements.
  • Otherwise, the resultant value is the product of all its elements.

Note: An array is said to be in strictly ascending order if for every index \(i\) with \(1 \le i < n\), the inequality \(a_i < a_{i+1}\) holds.

inputFormat

The input begins with an integer \(n\), representing the number of elements in the array. The second line contains \(n\) space-separated integers.

outputFormat

Output three space-separated integers: the smallest element, the largest element, and the computed sum (if the array is strictly ascending) or product (otherwise) of the elements.

## sample
5
1 2 3 4 5
1 5 15