Hallo - MarisaOJ: Marisa Online Judge

Hallo

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $a$ consisting of $n$ elements. The value of a contiguous subarray $a[l...r]$ is defined as $\text{min}(a_l, a_r) \times (r - l - 1)$. Find the maximum value of any contiguous subarray of the array $a$. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $a_i$. ### Output - Print a single integer representing the maximum value of any contiguous subarray. ### Constraints - $1 \leq n \leq 5 \times 10^5$. - $1 \leq a_i \leq 10^9$. ### Example Input: ``` 4 1 4 2 5 ``` Output: ``` 4 ```