You are given an array with n pairwise different values: A=\[a_0,a_1,…,a_n−1]. We define the sorted subarray of A starting at l and ending at r as the array that we obtain after sorting \[a_l,a_l+1,…,a_r]. For example, if we are given the array \[0,2,14,6,8,10], the sorted subarray starting at 1 and ending at 4 would be the array that we would get after sorting \[2,14,6,8], that is, the array \[2,6,8,14].
You are given q queries, each one consists of two integers, l and r. For each query, print the sum of the values in the even positions of the sorted subarray of A starting at l and ending at r. Here, we assume that all arrays are indexed starting from 0.
For example, consider the array \[0,2,14,6,8,10] and the query (1,4). The subarray starting at 1 and ending at 4 is just the array \[2,14,6,8]. Thus, the sorted subarray starting at 1 and ending at 4 is the array \[2,6,8,14]. Now we have to sum the values in even positions, that is, 2+8=10.
Print the answers modulo 109+7.
The first line contains two integers n and q (1≤n≤5⋅104; 1≤q≤2⋅105): the number of elements in the array and the number of queries.
The second line contains n integers a_0,a_1,…,a_n−1 (0≤a_i≤109; a_i are pairwise different), the elements of the array.
Finally, each of the next q lines contains two integers l and r (0≤l≤r<n): the starting and ending points of the sorted subarray we are considering.
For each query, print a line with the sum of the elements in even positions of the sorted subarray starting at l and ending at r modulo 109+7.