#include<bits/stdc++.h>

#define ll long long
#define vi vector<int>

using namespace std;

int arr[1<<20];
ll k;

void solve()
{
	int l, r;
	cin>>l>>r;
	cout<<(arr[l-1]-1)+(k-arr[r-1])+2*(arr[r-1]-arr[l-1]-r+l)<<endl;
}

int main()
{
	int n, q;
	cin>>n>>q>>k;
	for(int i = 0; i<n; i++) cin>>arr[i];

	while(q--)
		solve();
}
