#K4401. Merge Rows
Merge Rows
Merge Rows
You are given an integer n representing the number of rows and a sequence of n integers representing the value of each row. Your task is to merge all rows into a single row.
Each merge operation reduces the total number of rows by 1. Hence, for n rows, exactly \(n-1\) operations are needed. The final row's value is simply the sum of all the individual row values.
Calculate and output the minimum number of operations required along with the final row sum.
inputFormat
The input is provided through stdin in the following format:
- The first line contains a single integer \(n\) (1 ≤ \(n\) ≤ 105), denoting the number of rows.
- The second line contains \(n\) space-separated integers, each representing the value of a row.
outputFormat
Output two integers separated by a space on a single line: the minimum number of merge operations required and the final merged row value.
## sample4
4 3 2 6
3 15