{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"### Read problems statements in [Mandarin Chinese](https://www.codechef.com/download/translated/COOK128/mandarin/SUMGCD.pdf), [Russian](https://www.codechef.com/download/translated/COOK128/russian/SUMGCD.pdf), and [Bengali](https://www.codechef.com/download/translated/COOK128/bengali/SUMGCD.pdf) as well.\r\n\r\nChef has an array $a_1,\\ldots, a_n$ of $n$ elements. He wants you to answer queries of the following type: \r\n\r\nCompute $f(L, R)$, where $$f(L, R) \u003d \\sum_{i \u003d L}^{R} \\sum_{j\u003d i}^{R} \\gcd(a_i, a_{i+1}, \\dots a_j).$$ In other words, we want to compute the sum of the greatest common divisors over all subarrays of some range $[L, R]$. \r\nHelp Chef answer $q$ queries of the described type. \r\n\r\n\r\n### Input:\r\n\r\nThe first line contains two integers $n$ and $q$ - the size of the array and the number of queries.\r\n\r\nThe second line contains $n$ integers $a_1,\\ldots,a_n$.\r\n\r\nEach of the following $q$ lines contains two integers $l$, $r$.\r\n\r\nThe queries are encrypted. Let the answer to the previous query be $x$ (or $0$ if there is none). The query is decrypted as follows: $L\u003d((l+x)\\mod n)+1$ and $R\u003d((r+x) \\mod n)+1$.\r\n\r\n### Output:\r\n\r\nPrint $q$ integers - the answer to each query modulo $10^9+7$.\r\n\r\n### Constraints \r\n\r\n$1 \\leq n \\le 2\\cdot 10^5$\r\n\r\n$1 \\leq q \\le 10^6$\r\n\r\n$1 \\leq a_{i} \\le 10^9$\r\n\r\n$0 \\leq l, r \\le n$"}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 6\r\n\r\n18 12 30 35 63\r\n\r\n0 4\r\n\r\n4 5\r\n\r\n1 4\r\n\r\n1 3\r\n\r\n4 1\r\n\r\n3 5\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e193\r\n\r\n70\r\n\r\n161\r\n\r\n141\r\n\r\n78\r\n\r\n89\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\nThe decoded queries are respectively $f(1, 5)$; $f(3, 4)$; $f(2, 5)$; $f(3, 5)$; $f(1, 3)$; $f(2, 4)$"}}]}