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 sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush,heappop,heapify
from itertools import permutations,combinations
from itertools import accumulate as ac
mod = int(1e9)+7
#mod = 998244353
 
ip = lambda : int(stdin.readline())
inp = lambda: map(int,stdin.readline().split())
ips = lambda: stdin.readline().rstrip()
out = lambda x : stdout.write(str(x)+"\n")
 
t = 1
for _ in range(t):
    n,q,k = inp()
    arr = list(inp())
    if n == 1:
        for i in range(q):
            l,r = inp()
            ans = k-1
            print(ans)
    else:
        diff = []
        for i in range(n):
            if i == 0:
                cal = 0
                if arr[i] == 1:
                    pass
                else:
                    cal += arr[i]-1-1
            elif i == n-1:
                cal = 0
                if arr[i] == k:
                    pass
                else:
                    cal += k-arr[i]-1
            else:
                cal = 0
                cal += arr[i]-arr[i-1]-1
                cal += arr[i+1]-arr[i]-1
                    
            diff.append(cal)
        pref = [0]*n
        p = 0
        for i in range(n):
            p += diff[i]
            pref[i] = p
        
        for i in range(q):
            l,r = inp()
            l,r = l-1,r-1
            if l == r:
                ans = k-1
            elif r == l+1:
                ans = 0
                if arr[l] == 1:
                    pass
                else:
                    ans += arr[l]-1
                ans += arr[r]-arr[l]-1
                ans += arr[r]-arr[l]-1
                if arr[r] == k:
                    pass
                else:
                    ans += k-arr[r]
                
            else:
                ans = 0
                if arr[l] == 1:
                    pass
                else:
                    ans += arr[l]-1
                ans += arr[l+1]-arr[l]-1
                ans += arr[r]-arr[r-1]-1
                if arr[r] == k:
                    pass
                else:
                    ans += k-arr[r]
                l += 1
                r -= 1
                ans += pref[r]-pref[l]+diff[l]
            print(ans)
                
                
        
            
            
    
    
    
    
            
                
            
            
        
        
        
            
        
        



