Given a positive integer k, two arrays are called k-similar if:

  * they are strictly increasing; 
  * they have the same length; 
  * all their elements are positive integers between 1 and k (inclusive); 
  * they differ in exactly one position. 



You are given an integer k, a strictly increasing array a and q queries. For each query, you are given two integers l_i ≤ r_i. Your task is to find how many arrays b exist, such that b is k-similar to array [a_{l_i},a_{l_i+1}…,a_{r_i}]. 

Input

The first line contains three integers n, q and k (1≤ n, q ≤ 10^5, n≤ k ≤ 10^9) — the length of array a, the number of queries and number k.

The second line contains n integers a_1, a_2, …,a_n (1 ≤ a_i ≤ k). This array is strictly increasing — a_1 < a_2 < … < a_n.

Each of the following q lines contains two integers l_i, r_i (1 ≤ l_i ≤ r_i ≤ n).

Output

Print q lines. The i-th of them should contain the answer to the i-th query.

Examples

Input


4 2 5
1 2 4 5
2 3
3 4


Output


4
3


Input


6 5 10
2 4 6 7 8 9
1 4
1 2
3 5
1 6
5 5


Output


8
9
7
6
9

Note

In the first example:

In the first query there are 4 arrays that are 5-similar to [2,4]: [1,4],[3,4],[2,3],[2,5].

In the second query there are 3 arrays that are 5-similar to [4,5]: [1,5],[2,5],[3,5].
import java.util.*;

public class A {

    static int nCrModpDP(int n, int r, int p) {
        // The array C is going to store last row of
        // pascal triangle at the end. And last entry
        // of last row is nCr
        int[] C = new int[r + 1];

        C[0] = 1; // Top row of Pascal Triangle

        // One by constructs remaining rows of Pascal
        // Triangle from top to bottom
        for (int i = 1; i <= n; i++) {
            // Fill entries of current row using previous
            // row values
            for (int j = Math.min(i, r); j > 0; j--)

                // nCj = (n-1)Cj + (n-1)C(j-1);
                C[j] = (C[j] + C[j - 1]) % p;
        }
        return C[r];
    }

    // Lucas Theorem based function that returns nCr % p
    // This function works like decimal to binary conversion
    // recursive function. First we compute last digits of
    // n and r in base p, then recur for remaining digits
    static int nCrModpLucas(int n, int r, int p) {
        // Base case
        if (r == 0)
            return 1;

        // Compute last digits of n and r in base p
        int ni = n % p;
        int ri = r % p;

        // Compute result for last digits computed above, and
        // for remaining digits. Multiply the two results and
        // compute the result of multiplication in modulo p.
        return (nCrModpLucas(n / p, r / p, p) * // Last digits of n and r
                nCrModpDP(ni, ri, p)) % p; // Remaining digits
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        int n = sc.nextInt();
        int q = sc.nextInt();
        int k = sc.nextInt();

        int arr[] = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        if (n == 1) {
            for (int i = 0; i < q; i++) {
                sb.append(k - 1).append("\n");
            }
            System.out.println(sb);
            return;
        }

        int values[] = new int[n];

        values[0] = (arr[1] - 1);

        for (int i = 1; i < n - 1; i++) {
            values[i] = arr[i + 1] - arr[i - 1] - 1;
        }

        values[n - 1] = (k - arr[n - 1]);

        long pre_left[] = new long[n];

        pre_left[0] = values[0];

        for (int i = 1; i < n; i++) {
            pre_left[i] = pre_left[i - 1] + values[i];
        }

        for (int i = 0; i < q; i++) {
            int left = sc.nextInt() - 1;
            int right = sc.nextInt() - 1;

            if (left == right) {
                sb.append(k - 1).append("\n");
                continue;
            }

            long ans = arr[left + 1] - 1 + k - arr[right - 1] - 1;

            if (left + 1 == right) {
                sb.append(ans - 1).append("\n");
                continue;
            }

            ans = ans + pre_left[right - 1] - pre_left[left] - (right - 1 - left + 1);

            sb.append(ans).append("\n");

        }

        System.out.print(sb);
    }
}