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 os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


def inp():
    return sys.stdin.readline().rstrip()


def mpint():
    return map(int, inp().split(' '))


def itg():
    return int(inp())


# ############################## import
from itertools import accumulate


class PrefixArray:
    def __init__(self, seq):
        self.data = tuple(seq)
        self.prefix = tuple(accumulate(self.data))

    def __getitem__(self, item) -> int:
        """ :return sum(seq[start: end]) # [a, b) """
        if type(item) is int:
            return self.prefix[item]
        # is slice
        start = 0 if item.start is None else item.start % len(self)
        stop = len(self) if item.stop is None else item.stop % len(self)
        if stop == 0:
            return 0
        if start == 0:
            return self.prefix[stop - 1]
        return self.prefix[stop - 1] - self.prefix[start - 1]

    def __len__(self):
        return len(self.data)


# ############################## main
"""
you modify exactly one position to get b
for each position, it limited by adjacent positions

Divided into 3 situations:
is first, mid or last position
"""


def main():
    n, q, k = mpint()
    arr = tuple(mpint())
    first = [0] * n  # limited by a[i+1]
    mid = [0] * n  # limited by a[i-1] and a[i+1]
    last = [0] * n  # limited by a[i-1]
    if n > 1:
        for i in range(n - 1):
            first[i] = arr[i + 1] - 2
        for i in range(1, n - 1):
            mid[i] = arr[i + 1] - arr[i - 1] - 2
        for i in range(1, n):
            last[i] = k - arr[i - 1] - 1
    pa = PrefixArray(mid)

    for _ in range(q):
        lf, rg = mpint()
        if lf == rg:
            print(k - 1)
            continue
        lf -= 1
        rg -= 1
        ans = first[lf] + pa[lf + 1:rg] + last[rg]
        print(ans)


DEBUG = 0
URL = 'https://codeforces.com/contest/1485/problem/B'

if __name__ == '__main__':
    # 0: normal, 1: runner, 2: interactive, 3: debug
    if DEBUG == 1:
        import requests
        from ACgenerator.Y_Test_Case_Runner import TestCaseRunner

        runner = TestCaseRunner(main, URL)
        inp = runner.input_stream
        print = runner.output_stream
        runner.checking()
    else:
        if DEBUG != 3:
            sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
        if DEBUG:
            _print = print


            def print(*args, **kwargs):
                _print(*args, **kwargs)
                sys.stdout.flush()
        main()
# Please check!
