#K70247. Minimizing Final Merged Element Value
Minimizing Final Merged Element Value
Minimizing Final Merged Element Value
You are given a sequence of integers. The task is to merge adjacent elements repeatedly until only one element remains. At each step, you merge two adjacent numbers by replacing them with their sum. Your goal is to determine the minimum possible value of the final merged element.
Note that since the operation is addition which is associative, the final result is simply the sum of all elements in the array.
Input Format: The input starts with an integer n representing the number of elements. This is followed by a line with n space-separated integers.
Output Format: Print a single integer - the minimum possible value of the final element after all the merge operations.
Example:
Input: 4 4 2 3 7</p>Output: 16
inputFormat
The first line contains an integer n, the number of elements in the array.
The second line contains n space-separated integers.
outputFormat
Output a single integer, the minimum possible final merged element value (i.e., the sum of the array elements).
## sample4
4 2 3 7
16