Be Geeks!
Time limit2sMemory limit512 MB
Sum gcd(a_i..a_j) * max(a_i..a_j) over all subarrays, modulo 1e9+7, with N up to 2e5.
- Level
Hard9 of 10
- Topics
- Math, Number theory, Divide and conquer, Dynamic programming
- Solved
- No attempts yet
Problem
The musical band Be Geeks! did not get its name by accident, since every member is a genuine math geek. Among other things, they love examining various properties of number sequences. Here is one example of a subject that interests them.
- Let be a nonempty sequence of positive integers, .
- Let , where .
- Let , where .
- Let , where .
- Let , where the sum runs over all integer pairs .
The function stands for the greatest common divisor of the given values. The greatest common divisor of a nonempty sequence of integers is the largest integer that divides every integer in the sequence evenly.
Input
The first line contains one integer (). The next line contains integers ().
Output
Print the value of modulo .