#P6406. [COCI 2014/2015 #2] Norma
[COCI 2014/2015 #2] Norma
Description
Given a positive integer sequence , compute
$$\sum_{i=1}^{n}\sum_{j=i}^{n}(j-i+1)\min(a_i,a_{i+1},\cdots,a_j)\max(a_i,a_{i+1},\cdots,a_j)$$Input Format
The first line contains an integer .
The next lines each contain a positive integer, representing the input sequence .
Output Format
Output the result modulo .
4
2
4
1
4
109
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号