#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;

int n,q;
long long k,a[MAXN];
long long sum[MAXN];

template<typename Drake>
void Read(Drake &x){
	x=0;char ch=getchar();
	while(!isdigit(ch)){
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
}
 
int main(){
	Read(n);Read(q);Read(k);
	for(int i=1;i<=n;++i)Read(a[i]);
	sum[0]=0;
	sum[1]=a[2]-2;
	for(int i=2;i<n;++i)
	sum[i]=sum[i-1]+a[i+1]-a[i-1]-2;
	sum[n]=sum[n-1]+k-a[n-1]-1;
	while(q--){
		int l,r;long long ans;
		Read(l);Read(r);
		if(l==r){
			printf("%lld\n",k-1);
			continue;
		} 
		ans=sum[r-1]-sum[l];
		ans+=a[l+1]-2;
		ans+=k-a[r-1]-1;
		printf("%lld\n",ans);
	} 
	return 0;
}
