#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define rg register
inline int read(){
	rg int x=0,fh=1;
	rg char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*fh;
}
const int maxn=1e5+5;
int n,q,k,a[maxn];
long long sum[maxn];
int main(){
	n=read(),q=read(),k=read();
	for(rg int i=1;i<=n;i++) a[i]=read();
	a[n+1]=k+1;
	for(rg int i=1;i<=n;i++){
		sum[i]=sum[i-1]+(a[i]-a[i-1]-1)+(a[i+1]-a[i]-1);
	}
	rg int l,r;
	rg long long ans=0;
	for(rg int i=1;i<=q;i++){
		scanf("%d%d",&l,&r);
		if(l==r) ans=k-1;
		else {
			ans=sum[r-1]-sum[l];
			ans+=k-a[r-1]-1;
			ans+=a[l+1]-2;
		}
		printf("%lld\n",ans);
	}
	return 0;
}