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