#P13973. [VKOSHP 2024] Nightmare Sum
[VKOSHP 2024] Nightmare Sum
Description
Given an array of length , consisting of distinct positive integers. Compute
$$\sum\limits_{l=1}^{n} \sum\limits_{r=l}^{n} \left\lfloor\frac{\max(a_{l},a_{l+1},\ldots,a_{r})}{\min(a_{l},a_{l+1},\ldots,a_{r})}\right\rfloor$$Here, denotes rounded down to the nearest integer.
Thus, it is necessary to compute the sum of the results of integer division of the maximum by the minimum over all subarrays of the array .
Input Format
The first line of input contains a single integer ~--- the length of the array .
The second line of input contains integers~--- the array .
It is guaranteed that all numbers in the array are distinct.
Output Format
Output a single number --- the desired sum.
6
1 3 6 4 2 5
56
Hint
Let's consider the example in more detail:
:::align{center}
:::
京公网安备 11011102002149号