// Problem: B. Replace and Keep Sorted
// Contest: Codeforces - Codeforces Round #701 (Div. 2)
// URL: https://codeforces.com/contest/1485/problem/B
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <cstdio>
#include <cctype>

template <typename Tp>
void read(Tp &res){
	static char ch; ch = getchar(), res = 0;
	static bool flag; flag = 0;
	while(!isdigit(ch)) flag = (ch == '-'), ch = getchar();
	while(isdigit(ch)) res = res * 10 + ch - 48, ch = getchar();
	if(flag) res = -res;
}

const int maxn = 1e5 + 19;

int n, q, k, a[maxn], s[maxn];

int main(){
	read(n), read(q), read(k);
	for(int i = 1; i <= n; ++i) read(a[i]);
	for(int i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i] - a[i - 1] - 1;
	while(q--){
		int l, r;
		read(l), read(r);
		printf("%lld\n", (long long)(s[r] - s[l]) * 2 + a[l] - 1 + k - a[r]);
	}
}