#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[100005],b[100005];
int main(){
    int n,q,k;
    cin>>n>>q>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<n;i++){
        b[i]=a[i+1]-a[i-1]-2;
        b[i]+=b[i-1];
    }
    while(q--){
        int l,r;
        cin>>l>>r;
        if(l==r){
            cout<<k-1<<endl;
            continue;
        }
        ll ans=0;
        ans+=a[l+1]-2;
        ans+=k-a[r-1]-1;
        ans+=b[r-1]-b[l];
        cout<<ans<<endl;
    }
}
