report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Product - MarisaOJ: Marisa Online Judge

Product

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers. Let's denote function $f(l, r)$ as: $$max(A_{l...r}) \times min(A_{l...r})$$ Calculate: $$ \sum_{l=1}^{n} \sum_{r=l}^{n} f(l, r) $$ ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the result, modulo $10^9+7$. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i \le 10^9$. ### Example Input: ``` 4 1 4 3 1 ``` Output: ``` 58 ```
Divide and conquer
Product
Big board
Segment queries
xor xor xor
Coins flip
Slimes
4D longest path
Good subarray
Shortest path on grid
Dynamic MST
Topic
Prefix sum
Divide and conquer
Rating 1900
Solution (1) Solution