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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	static InputReader ir;
	static OutputPrinter op;
	static int n;
	static int q;
	static int k;
	static int[] vals;
	static int[] l;
	static int[] r;

	public static void main(String[] args) throws IOException {
		ir = new InputReader();
		op = new OutputPrinter();
		n = ir.nextInt();
		q = ir.nextInt();
		k = ir.nextInt();
		vals = new int[n];
		l = new int[q];
		r = new int[q];
		for (int i = 0; i < n; i++) {
			vals[i] = ir.nextInt();
		}
		for (int i = 0; i < q; i++) {
			l[i] = ir.nextInt() - 1;
			r[i] = ir.nextInt() - 1;
		}
		f();
	}

	public static void f() throws IOException {
		if (n == 1) {
			for (int i = 0; i < q; i++) {
				op.writeln(k-1);
			}
		}
		else {
		// l and r freely move, things in the middle are restricted
		int[] possibilities = new int[n];
		for (int i = 1; i < n - 1; i++) {
			possibilities[i] += vals[i + 1] - vals[i] - 1;
			possibilities[i] += vals[i] - vals[i - 1] - 1;
		}
		int[] presum = new int[n];
		presum[1] = possibilities[1];
		for (int i = 2; i < n - 1; i++) {
			presum[i] = possibilities[i] + presum[i - 1];
		}
		for (int i = 0; i < q; i++) {
			int left = l[i];
			int right = r[i];
			if (left == right) {
				op.writeln(k - 1);
			} else {
				int result = 0;
				result += vals[left] - 1;
				result += vals[left + 1] - vals[left] - 1;
				result += k - vals[right];
				result += vals[right] - vals[right - 1] - 1;
				result += presum[right - 1] - presum[left];
				op.writeln(result);
			}
		}
	}}

	public static int getMin(long a, long b) {
		int num = 0;
		while (a != 0) {
			a /= b;
			num++;
		}
		return num;
	}
}

class InputReader {
	public BufferedReader br;
	public StringTokenizer st;

	public InputReader() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	public int nextInt() throws IOException {
		if (st == null) {
			st = new StringTokenizer(br.readLine());
		}
		if (st.hasMoreElements()) {
			return Integer.parseInt(st.nextToken());
		} else {
			st = new StringTokenizer(br.readLine());
			return Integer.parseInt(st.nextToken());
		}
	}

	public double nextDouble() throws IOException {
		if (st == null) {
			st = new StringTokenizer(br.readLine());
		}
		if (st.hasMoreElements()) {
			return Double.parseDouble(st.nextToken());
		} else {
			st = new StringTokenizer(br.readLine());
			return Double.parseDouble(st.nextToken());
		}
	}

	public String nextToken() throws IOException {
		if (st == null) {
			st = new StringTokenizer(br.readLine());
		}
		if (st.hasMoreElements()) {
			return st.nextToken();
		} else {
			st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}
}

class OutputPrinter {
	public PrintWriter pw;

	public OutputPrinter() {
		pw = new PrintWriter(new OutputStreamWriter(System.out), true);
	}

	public void write(char[] buf) throws IOException {
		pw.write(buf);
		pw.flush();
	}

	public void writeln(char[] buf) throws IOException {
		write(buf);
		pw.write("\n");
		pw.flush();
	}

	public void write(String s) throws IOException {
		pw.write(s);
		pw.flush();
	}

	public void writeln(String s) throws IOException {
		write(s);
		pw.write("\n");
		pw.flush();
	}

	public void write(int t) throws IOException {
		pw.write(Integer.toString(t));
		pw.flush();
	}

	public void writeln(int t) throws IOException {
		write(t);
		pw.write("\n");
		pw.flush();
	}

	public void write(double d) throws IOException {
		pw.write(Double.toString(d));
		pw.flush();
	}

	public void writeln(double d) throws IOException {
		write(d);
		pw.write("\n");
		pw.flush();
	}

	public void writeln() {
		pw.write("\n");
		pw.flush();
	}
}