The author has used up all the creative skills on previous problems, so Anton won't be tortured in this statement. He will just give you an interesting problem.
You are given an array $$$a$$$ consisting of $$$n$$$ integers. You are also given $$$q$$$ queries $$$[l;r]$$$. For each query, find the maximum value of $$$\operatorname{sum}[tl;tr] \times \operatorname{gcd}[tl;tr]$$$ over all pairs ($$$tl;tr$$$), where
The greatest common divisor of two numbers $$$a$$$ and $$$b$$$ is the largest positive integer $$$x$$$ that divides both $$$a$$$ and $$$b$$$.
The greatest common divisor of a set of numbers is the largest positive integer $$$x$$$ that divides all elements of the set.
The first line contains two integers $$$n$$$, $$$q$$$ ($$$1 \le n, q \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of queries, respectively.
The second line contains $$$n$$$ integers $$$a_i$$$ ($$$1 \le a_i \le 6 \cdot 10^6$$$) — the description of the array.
Each of the next $$$q$$$ lines contains two integers $$$l$$$, $$$r$$$ ($$$1 \le l \le r \le n$$$) — the description of the queries.
Print $$$q$$$ integers — the answers to the queries.
3 23 3 21 32 3
18 9
8 62 4 8 8 8 2 4 161 82 53 42 47 73 6
256 192 128 128 16 192
In the first example, there are following segments: