You are given an array of positive integers.
In one operation, choose two adjacent elements and and replace them with the single number . The other elements keep their relative order.
Find the minimum possible value of the remaining element after operations.
Merge the two elements equal to , obtaining . Merge the remaining pair to obtain . Since every merge produces a number at least , this is optimal.
The first operation produces either or . In both cases, the final operation produces .
Merge the first two elements, obtaining . Merge the last two elements to obtain , and then merge once more to obtain . No order of operations produces a value smaller than .