#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 998244353
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
const int N=2e5+10;
////////////////////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll ncr( ll n , ll r, ll p , ll fact[] )
{
    if( n<r )
    return 0;
    if( r==0 )
    return 1;
    return (fact[n]* modInverse(fact[r], p) % p * 
            modInverse(fact[n-r], p) % p) % p; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  

    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  

    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}  
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    if( x.val == y.val )
    {
        return x.ind>y.ind;
    }
    return x.val>y.val;
}
////////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tc=1;
    //cin>>tc;
    while(tc--)
    {
        ll n,q,k;
        cin>>n>>q>>k;
        ll a[n+2];
        a[0]=0;
        a[n+1]=k+1;
        rep(i,1,n+1)
        {
            cin>>a[i];
        }
        ll dp[n+1];
        dp[0]=0;
        rep(i,1,n+1)
        {
            dp[i]=dp[i-1];
            dp[i]+=a[i]-a[i-1]-1;
            dp[i]+=a[i+1]-a[i]-1;
        }
        while(q--)
        {
            ll l,r;
            cin>>l>>r;
            cout<<a[l]-1+k-a[r]+dp[r]-dp[l-1]-(a[l]-a[l-1]-1)-(a[r+1]-a[r]-1)<<'\n';
        }
    }
}
