A pair of distinct positive integers is said to be a coprime-twin pair, if for all positive integers , both and are coprime to or both and are not coprime to . Formally, 2 distinct positive integers and can form a coprime-twin pair if and only if , where denotes the set of all positive integers that are coprime to . For example,
The score of a sequence is the number of indices such that and the pair forms a coprime-twin pair.
You are given an array of positive integers and queries of the form . For each query, determine the sum of the scores of all subarrays that completely lie within the range (both inclusive).
Note: A subarray is a contiguous non-empty segment of the array. If a subarray completely lies within the range , then it means that both its endpoints lie within this range.
Input format
Output format
For each query, print the answer to the query in a new line as mentioned in the problem statement.
Constraints
For the first query, there are no coprime-twin pairs in this range.
For the second query, is the only subarray having score 1 (because of the coprime-twin pair ). All other subarrays have score 0.
For the third query, the subarrays and their scores are :
The sum of the scores is therefore, .
The answers to the remaining queries can be found similarly.