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 bisect
import math
import itertools
import sys
# import sys.stdout.flush() use for interactive problems
from typing import List

alpha = 'abcdefghijklmnopqrstuvwxyz'

primes = []
prime = [True for i in range(10**6+1)]
p = 2
while (p * p <= 10**6):

    # If prime[p] is not
    # changed, then it is a prime
    if (prime[p] == True):

        # Update all multiples of p
        for i in range(p * p, 10**6+1, p):
            prime[i] = False
    p += 1

for p in range(2, 10**6+1):
    if prime[p]:
        primes.append(p)



def solve(n,q,k,a,queries):
    answers = []
    a = [0]+a+[k+1]
    pre = []
    pre_first = []
    pre_last = []
    for i in range(1,n+1):
        pre.append(max(-a[i-1]+a[i+1]-2,0))
        pre_first.append(a[i+1]-2)
        pre_last.append(k+1-a[i-1]-2)
    #print(pre)
    #print(pre_first)
    #print(pre_last)
    pre_sum = [0]
    sum = 0
    for i in range(n):
        sum += pre[i]
        pre_sum.append(sum)
    #print(pre_sum)
    for i in range(q):
        l = queries[i][0]
        r = queries[i][1]
        answers.append(pre_first[l-1]+pre_last[r-1]+pre_sum[r-1]-pre_sum[l])
        #print(answers)
    for answer in answers:
        print(answer)


    pass


t = 1#int(input())
ans = []
for _ in range(t):
    #n = int(input())
    #s = input()
    n,q,k = map(int, input().split())
    # arr = list(input())
    # strings = [str(x) for x in input().split()]
    # a = [int(x) for x in input().split()]
    # b = [int(x) for x in input().split()]
    # painters = [int(x) for x in input().split()]
    # ls = [int(x) for x in input().split()]
    # n = nk[0]
    # k = nk[1]

    # k = nmk[2]
    a = [int(x) for x in input().split()]
    # s1 = input()
    # s2 = input()
    # x = xy[0]
    # y = xy[1]
    # x = xy[0]
    # y = xy[1]
    # a = [int(x) for x in input().split()]
    # b = [int(x) for x in input().split()]
    # s = input()
    # grid = []
    # for j in range(n):
    #     arr = list(input())
    #     grid.append(arr)
    # options = [int(x) for x in input().split()]
    """cs = []
    for j in range(nx1y1x2y2c[-1]):
        cs.append([int(x) for x in input().split()])"""
    queries = []
    for j in range(q):
        queries.append(list(map(int, input().split())))
    # s = list(input())
    # start,end = map(int,input().split())

    ans.append(solve(n,q,k,a,queries))

