#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,q,k,a[100005],f[100005],s[100005];
void solve()
{
	scanf("%lld%lld%lld",&n,&q,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<n;i++) f[i]=a[i+1]-a[i-1]-2;
	f[n]=k-a[n-1]-2;
	for(int i=1;i<=n;i++) s[i]=s[i-1]+f[i];
	//for(int i=1;i<=n;i++) cout<<s[i]<<" ";
	//puts("");
	while(q--)
	{
		int l,r;
		scanf("%lld%lld",&l,&r);
		if(l==r) printf("%lld\n",k-1);
		else 
		{
			if(r==l+1)
			{
				printf("%lld\n",max(0LL,a[l+1]-2+k-a[r-1]-1));
			}
			else printf("%lld\n",max(0LL,a[l+1]-2+k-a[r-1]-1+s[r-1]-s[l]));
		}
	}
}
signed main()
{
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}