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].
//package codeforce.div2.r701;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author pribic (Priyank Doshi)
 * @since 12/02/21
 */
public class B {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int T = 1;//sc.nextInt();
      for (int tt = 1; tt <= T; tt++) {
        int n = sc.nextInt(), q = sc.nextInt(), k = sc.nextInt();
        int[] raw = new int[n];
        for (int i = 0; i < n; i++) {
          raw[i] = sc.nextInt();
        }
        int[] ways = new int[n];
        for (int i = 0; i < n; i++) {
          if (i == 0) {
            ways[i] = (n == 1 ? k - 1 : (raw[i + 1] - 2));
          } else if (i == n - 1) {
            ways[i] = k - raw[i - 1] - 1;
          } else {
            ways[i] = raw[i + 1] - raw[i - 1] - 2;
          }
        }
        long[] prefixSum = new long[n];
        long curSum = 0;
        for (int i = 0; i < n; i++) {
          prefixSum[i] = curSum + ways[i];
          curSum += ways[i];
        }
        //System.out.println("ways = " + Arrays.toString(ways));
        //System.out.println("prefix = " + Arrays.toString(prefixSum));
        while (q-- > 0) {
          int l = sc.nextInt() - 1, r = sc.nextInt() - 1;
          if (l == r) {
            //ways[l] = 10
            //k = 20 -> 20 - 1 - 1 = 18
            //k = 10 | 8 -> 10 - 1 |
            System.out.println(k - 1);
          } else {
            long ans = Math.max(0, raw[l + 1] - 2);
            ans += (k - raw[r - 1] - 1);
            if (r > l + 1)
              ans += (prefixSum[r - 1] - prefixSum[l]); //sum of [l + 1, r - 1]
            System.out.println(ans);
          }
        }
      }
    }
  }
}