Dynamic array
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
The teacher writes numbers on the board. Then, until the count of numbers written on the board reaches , the students approach the board one by one, choose any two consecutive numbers currently written on the board, and write the sum of these two numbers between them.
Find the smallest possible value of the largest number written on the board.
Input
The first line contains two integers and . The next line contains integers .
Output
Print the smallest possible value of the largest number written on the board.
Examples
Example 1.
Example 2.
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 333
Acceptance rate 25%