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].
//**sn0wrus**//
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cout.tie(NULL);                   \
    cin.tie(NULL);
#define write(a)          \
    for (auto x : a)      \
    {                     \
        cout << x << " "; \
    }                     \
    cout << endl;
#define read(a)       \
    for (auto &x : a) \
    {                 \
        cin >> x;     \
    }
#define IN cin >>
#define OUT cout <<
#define endl "\n"
#define all(a) (a).begin(), (a).end()
#define allr(a) (a).rbegin(), (a).rend()
#define pb push_back
#define fi first;
#define se second;

using ll = long long int;
using ld = long double;
using pll = pair<ll, ll>;   
using pii = pair<int, int>;
using plll  = pair<ll,pll>;
using vll = vector<ll>;
using vi = vector<int>;
const ll mod = (ll)(1e9) + 7LL;
const ll M = 998244353LL;

const int dir8[8][2]={{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
const int dir4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};

/*
for(int i=0;i<n-1;i++)
{
    int a,b;
    cin>>a>>b;
    a--,b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
}
*/

void solve()
{
	ll n,q,k;
    cin>>n>>q>>k;
    vector<ll>arr(n);
    for(int i=0;i<n;i++)cin>>arr[i];

    vector<ll>beg(n,0);
	vector<ll>end(n,0);
	vector<ll>mid(n,0);

	for(int i=0;i<n;i++)
	{
		if(i==(n-1))
		{
			beg[i]=k-1;
		}
		else{
			ll x = arr[i+1];
			beg[i]=x-2;
		}
	}
	//write(beg);
	for(int i=1;i<n-1;i++)
	{
		ll x=arr[i-1];
		ll y = arr[i+1];
		mid[i]=y-x-2;
		mid[i]+=mid[i-1];
	}
	//write(mid);
	mid[n-1]+=mid[n-2];
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			end[i]=k-1;
		}
		else{
			ll x = arr[i-1];
			end[i]=k-x-1;
		}
	}
	//write(end);
    while(q--)
    {
    	ll l,r;
    	
    	cin>>l>>r;
    	l--;r--;
    	if(l==r)
    	{
    		cout<<k-1<<endl;
    		continue;
    	}
    	ll ans=0;
    	ans+=beg[l];
    	ans+=end[r];
    	ans+=(mid[r-1]-mid[l]);
    	cout<<ans<<endl;
    }
    return;
}

int main()
{
    fast;
    ll tc = 1;
    //IN tc;
    while (tc--)
    {
        solve();
    }
    return 0;
}