#include<stdio.h>
#define N 100007 
#define ll long long

inline int read(){
	int x=0,flag=1; char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') flag=0;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-48;c=getchar();}
	return flag? x:-x;
}

int n,q,k,a[N];
ll s[N];
 
int main(){
	n=read(),q=read(),k=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=2;i<n;i++) s[i]=a[i+1]-a[i-1]-2+s[i-1];
	while(q--){
		int l=read(),r=read();
		if(l==r) printf("%d\n",k-1);
		else{
			ll ans=a[l+1]+k-a[r-1]-3;
			if(l+1<r) ans+=s[r-1]-s[l];
			printf("%lld\n",ans);
		}
	}
}