#P10162. [DTCPC 2024] 序列
[DTCPC 2024] 序列
Problem Description
Define the weight of a sequence of length as . In particular, define .
Compute $\sum\limits_{l=1}^n \sum\limits_{r=l+1}^n f(\{a_l,a_{l+1},\dots,a_r\})$.
The answer is taken modulo .
Input Format
The first line contains a positive integer ().
The second line contains integers ().
Output Format
Output one number representing the answer.
The answer is taken modulo .
5
1 3 5 2 3
21
4
4 6 3 3
12
Hint
Translated by ChatGPT 5