#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<functional>
#include<queue>
#include<map>
#include<cstring>
 
#define rep(i,x,n) for(int x = i; x <= n; ++x)
#define FOR0(x, n) for(int x = 0; x < n; ++x)
#define FOR1(x, n) for(int x = 1; i <= n; ++x)
#define vt vector
#define endl "\n"
#define all(c) (c).begin(), (c).end()
#define msl(arr) memset(arr,0x3f,sizeof(arr))
#define mss(arr) memset(arr,0x7f,sizeof(arr))
#define msz(arr) memset(arr,0,sizeof(arr))
#define INF 987654321
#define sz(x) (int)(x).size()

#define MAX 100010
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

ll arr[MAX];
ll dp[MAX];
int T,n,q,k;
void solve(){
	arr[0] = 0;
	arr[n+1] = k;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];	
	}
	for(int i = 1; i <= n; i++){
		dp[i] = arr[i] - arr[i-1] -1 + dp[i-1];
	}
	
	for(int i = 1; i <= q; i++){
		int s, e;
		cin >> s >> e;
		cout << (dp[e] - dp[s]) * 2 + arr[s] - 1 + k - arr[e] << "\n";
	}
	
	
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> q >> k;
	solve();
	cout << endl;

	return 0;
}