#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define sorti sort(v.begin(),v.end())
#define rever reverse(v.begin(),v.end())
#define ll long long
#define refi for(i=0;i<n;i++)
#define maxn 10005
#define ff first
#define ss second
#define pii pair<long long,long long>
/*vector<long long> b(100009,0);//for prime check
void prime()
{
    long long y,j,i;
    long long x=sqrt(100009);
    for (i=3; i<=x; i=i+2)
    {
        for(j=i*i; j<=100009; j=j+i*2)
        {
            if(b[j]==0)
            {
                b[j]=1;
            }
        }
    }
}
vector<ll> prime_fac(ll n)
{
    ll i,a;
    vector<ll>factor;
    if(n%2==0)
    {
        while(n%2==0)
        {
            factor.pb(2);
            n=n/2;
        }
    }
    for(i=3; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
            {
                factor.pb(i);
                n=n/i;
            }
        }
    }
    if(n>2)
    {
        factor.pb(n);
    }
    return factor;
}
vector<ll> divisor(ll n)
{
    ll i,a;
    vector<ll>v;
    for(i=2; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            v.pb(n/i);
        }
    }
    return v;
}
ll modinverse(ll x)
{
    ll res=1;
    x=x%mod;
    ll y=mod-2;
    while(y>0)
    {
        if(y%2!=0)
        {
            res=(res*x)%mod;
        }
        y=y/2;
        x=(x*x)%mod;
    }
    return res;
}
ll ncr(int n, int k)
{
    if (k < 0 || k > n)
        return 0;
    return (arr[n] * inv[k]%mod * inv[n - k]%mod)%mod ;
}*/
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    ll n,i,k,x,y,ans,q,l,r;
    cin>>n>>q>>k;
    vector<ll>v(n+2),pre(n+2);
    for(i=1; i<=n; i++)
    {
        cin>>v[i];
    }
    v[0]=0;
    v[n+1]=k+1;
    pre[0]=0;
    for(i=1; i<=n; i++)
    {
        x=v[i-1]+1;
        y=v[i+1]-1;
        y-=x;
        pre[i]=pre[i-1]+y;
    }
    while(q--)
    {
        cin>>l>>r;
        if(l==r)
        {
            cout<<k-1<<endl;
        }
        else
        {
            ans=0;
            ans+=v[l+1]-2;
            ans+=k-(v[r-1]+1);
            ans+=(pre[r-1]-pre[l]);
            cout<<ans<<endl;
        }
    }
}
