After finally constructing his natural park, Lazy Bob can rest. Or can he? Climate change is worsening everyday, so Bob feels like he needs to spread awareness about it!
There are $$$N$$$ different animals in Bob's natural park, each of which can be represented by two integers: $$$c_i$$$, and $$$s_i$$$. $$$i$$$ represents its index, $$$c_i$$$ represents the species of the animal, and $$$s_i$$$ represents the skill of the animal of spreading the news further.
Because Lazy Bob really hates doing work, he loves arranging awareness meetings, and animals love to attend them, too. There are free cookies—and of course, they get to meet with their friends. One day, Lazy Bob decides to ask himself: how much awareness could he spread if he arranged every possible awareness meeting?
A possible meeting is defined as some sequence of animals with consecutive indices, or in other words, a subarray of the $$$N$$$ animals. The awareness created in a possible meeting is the product of two values: the number of distinct species $$$c_i$$$ of animals at the meeting raised to the power of $$$3366$$$, and the sum of all of their skill values $$$s_i$$$.
If two animals had a meeting, and their categories were $$$[1,2]$$$ and skill values were $$$[7,12]$$$, the total awareness would be $$$2 \cdot (7+12) = 38$$$.
Because Lazy Bob is very curious, but lazy, he tasks you with finding this total awareness value. The sum can formally be written as:
$$$\sum_{i=1}^N \sum_{j=i}^N \left(\left(\sum_{k=i}^j s_k \right) \cdot f(i, j)^{3366} \right)$$$, where $$$f(i, j)$$$ is the number of distinct species, $$$c_i$$$, between indices $$$i$$$ and $$$j$$$.
Line $$$1$$$: One integer $$$N$$$ ($$$1 \le N \le 10^5$$$).
Lines $$$2 \dots N+1$$$: Two space separated integers: $$$c_i$$$ ($$$1 \le c_i \le 50$$$), and $$$s_i$$$ ($$$1 \le s_i \le 10^4$$$), each describing the $$$i$$$th individual.
Line $$$1$$$: One integer representing the total sum of the awareness values of all possible meetings. Since this answer might be large, please output the remainder when the answer is divided by $$$10^9+7$$$.
4 3 2 1 10 1 6 2 3
858931320
| Название |
|---|


